Sobes.tech
Middle+

Design a database for a library: main tables, entities, relationships between them.

sobes.tech AI

Answer from AI

For the library, you can design the following database with main tables and relationships:

  • Books

    • id (PK)
    • title
    • author_id (FK)
    • publisher_id (FK)
    • year_published
    • isbn
    • copies_available
  • Authors

    • id (PK)
    • name
    • birth_date
  • Publishers

    • id (PK)
    • name
    • address
  • Members

    • id (PK)
    • name
    • membership_date
    • contact_info
  • Loans

    • id (PK)
    • book_id (FK)
    • member_id (FK)
    • loan_date
    • return_date

Relationships:

  • One author can have many books (1:N)
  • One publisher can publish many books (1:N)
  • One library member can borrow many books (1:N through Loans)
  • Each book can be issued multiple times at different times (through Loans)

This design allows storing information about books, their authors and publishers, as well as tracking the issuance of books to library members.