Library data modeling

database-design

enter image description here

I'm going to implement a library system as a web application. And I decided to use this library schema. But there are some problems which I don't understand.

  1. The Books entity, is it possible to use isbn as a primary key?
  2. Is there a possible relationship between the Books entity and the Libraries entity? Is it a correct many-to-many relationship? I think that any book must be in only one library. So it is considered that one-to-many is more appropriate.

Best Answer

Your model completely ignores the fact that books come in multiple copies.

Each copy of a book can only be in one place at one time, but each place could have multiple copies of any given book.

Since each copy of a book will have exactly the same ISBN, the answer to your first question is: "No, ISBN is not a sufficient primary key for Books."

What you need to account for is a Title entity. This is going to be a combination of what you're thinking about for your Books entity. A Title is an abstract object. It will have a title, authors, publication date, and so forth. You might even want to consider making a distinction between Title and Edition, since a book can be republished many times with variations each time.

Whether or not you want to distinguish between editions of a title, you must at least distinguish between Title and Books. The answer to your second question is that each physical book will be in one place (either at a Library or on loan to a Member - or in transit between branches, or lost, etc. - depending on how sophisticated you want your model to be).

On the other hand, Titles, (or Editions) will be many-to-many with locations.