Untitled

 avatar
unknown
plain_text
2 years ago
1.3 kB
5
Indexable
model Book {
  id            Int      @id @default(autoincrement())
  isbn          String   @unique
  title         String
  publisher     String
  author        Author   @relation(fields: [authorId], references: [id])
  authorId      Int
  publishedDate DateTime
  pageCount     Int
  genres        Genre[]  @relation(references: [id])
  description   String
  language      String
  coverImageUrl String
  createdAt     DateTime @default(now())
  updatedAt     DateTime @updatedAt
  ratings       Rating[]
  reviews       Review[]
}

model Genre {
  id    Int    @id @default(autoincrement())
  name  String
  books Book[] @relation(references: [id])
}

model Author {
  id    Int    @id @default(autoincrement())
  name  String
  books Book[]
}

model Rating {
  id     Int    @id @default(autoincrement())
  score  Float
  book   Book   @relation(fields: [bookId], references: [id])
  bookId Int
  user   User   @relation(fields: [userId], references: [id])
  userId Int
}

model User {
  id      Int      @id @default(autoincrement())
  name    String
  ratings Rating[]
  reviews Review[]
}

model Review {
  id      Int    @id @default(autoincrement())
  content String
  book    Book   @relation(fields: [bookId], references: [id])
  bookId  Int
  user    User   @relation(fields: [userId], references: [id])
  userId  Int
}
Editor is loading...
Leave a Comment