import "./data" connector { provider: .sqlite, url: "sqlite:test_connectors_sqlite_relations.sqlite", } server { bind: ("0.0.0.0", 4050), } // User & Profile represents an 1 to 1 required relationship model User { @id @autoIncrement @readonly id: Int @unique name: String @relation(fields: .id, references: .userId) profile: Profile } model Profile { @id @autoIncrement @readonly id: Int @unique name: String @foreignKey userId: Int @relation(fields: .userId, references: .id) user: User } // Player & KOFPlayer represents an 1 to 1 optional relationship model Player { @id @autoIncrement @readonly id: Int @unique name: String @relation(fields: .id, references: .playerId) kof: KOFPlayer? } model KOFPlayer { @id @autoIncrement @readonly id: Int @unique name: String @foreignKey playerId: Int? @relation(fields: .playerId, references: .id) player: Player? } // Event & Note represents an 1 optional to 1 required relationship model Event { @id @autoIncrement @readonly id: Int @unique name: String @foreignKey noteId: Int? @relation(fields: .noteId, references: .id) note: Note? } model Note { @id @autoIncrement @readonly id: Int @unique name: String @relation(fields: .id, references: .noteId) event: Event } // Game & CommandList represents an 1 optional to 1 required relationship model Game { @id @autoIncrement @readonly id: Int @unique name: String @relation(fields: .id, references: .gameId) commandList: CommandList? } model CommandList { @id @autoIncrement @readonly id: Int @unique name: String @foreignKey gameId: Int @relation(fields: .gameId, references: .id) game: Game } // Product & Category represents an 1 optional to many relationship model Product { @id @autoIncrement @readonly id: Int @unique name: String @foreignKey categoryId: Int? @relation(fields: .categoryId, references: .id) category: Category? } model Category { @id @autoIncrement @readonly id: Int @unique name: String @relation(fields: .id, references: .categoryId) products: Product[] } // Author & Post represents an 1 required to many relationship model Author { @id @autoIncrement @readonly id: Int @unique name: String @relation(fields: .id, references: .authorId) posts: Post[] } model Post { @id @autoIncrement @readonly id: Int @unique name: String @foreignKey authorId: Int @relation(fields: .authorId, references: .id) author: Author } // Artist & Song represents a many to many relationship model Artist { @id @autoIncrement @readonly id: Int @unique name: String @relation(through: Perform, local: .artist, foreign: .song) songs: Song[] } model Song { @id @autoIncrement @readonly id: Int @unique name: String @relation(through: Perform, local: .song, foreign: .artist) artists: Artist[] } @id([.artistId, .songId]) model Perform { @foreignKey artistId: Int @foreignKey songId: Int @relation(fields: .artistId, references: .id) artist: Artist @relation(fields: .songId, references: .id) song: Song }