Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.3 kB
3
Indexable
Never
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
}
Leave a Comment