Database Design – Can’t Finish ER Diagram

database-design

I am trying to create a database for a small book library. This is not a professional project, just an exercise of my own. This is my first time to try this ( I am self-taught ) and I am encountering a problem. Before I continue I will provide my version of the ER diagram below ( I made it in Paint, using the following resource for notation ):

enter image description here

My biggest problem is to solve the fact that book can have the same title but have several editions or be a part of a set. An example would be Lord of the Rings trilogy, or Programming Windows, 5th edition, or Encyclopaedia of chess openings, volume D.

I don't know how to incorporate this into my ER diagram so that I can avoid data redundancy.

Therefore I ask these questions:

  • How should I address the fact that book can have the same title but have several editions or be a part of a set, in my ER diagram?

  • Since I am inexperienced, can you point out mistakes in my ER diagram, if there are any, and suggest an improvement?

Since this is my very first post here, please leave a comment if anything needs to be changed ( if it doesn't fit this site's question format ) or if you need further info.

Thank you.

Best Answer

I think if you look at your model and you consider the requirements that it doesn't handle (i.e. your questions) then you will find that you need to expand your model somewhat. Consider the following ERD:

(Note I use the James Martin crows foot notation which is a little more compact than what you have used but should be pretty simple to understand. The only slightly distinct feature is the use of an upper case "I" to indicate that a relationship is part of the identifier of the entity)

ERD

Here are some points that this ERD addresses:

  • A BOOK which can be rented is a physical thing (assuming you're dealing with paper books). That means that you need to allow for having more than one copy. Therefore a book has a title, but it isn't the same thing as the title, so my model makes TITLE its own entity.

  • Depending on whether you want a snapshot of which books are rented and to whom or whether you want an audit trail of which books have been rented to whom, you need to have either a 0,1-to-many or a many-to-many relationship to represent the rental status of each (physical) book.

  • Each BOOK has an EDITION. This doesn't have to be a special edition. It could be first edition, paperback, special edition, etc. etc.

  • An EDITION will have a TITLE. Every edition of the same book will have the same title so the relationship to TITLE belongs at the EDITION level.

  • Similarly, every edition will be published by the same publisher (or group of publishers) whereas different editions may have different publishers. Since you can have more than one publisher, this needs to have a many-to-many relationship between PUBLISHER and EDITION.

  • A TITLE can have multiple authors, so a many-to-many relationship is required between TITLE and WRITER.