Senior
You need to describe the library model. There are 3 entities: "Author", "Book", "Reader" -- Physically, there is only one book and it can only be with one reader. You need to create tables for the library to reflect this. -- A book can have multiple authors.
sobes.tech AI
Answer from AI
To describe the library model considering the conditions, the following tables can be used:
- Authors:
- id (PK)
- name
- Books:
- id (PK)
- title
- reader_id (FK, nullable) — indicates the reader who currently owns the book; null if the book is available
- Readers:
- id (PK)
- name
- BookAuthors (many-to-many relationship between books and authors):
- book_id (FK)
- author_id (FK)
Features:
- A book physically exists and can be owned by one reader, so the reader_id field in the Books table stores the current owner.
- To link multiple authors to a single book, an intermediate table BookAuthors is used.
This design ensures:
- Tracking the current owner of the book (one reader per book).
- The relationship of a book with multiple authors.