HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Database model about libraries

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
databaselibrariesmodelabout

Problem

I need to make database model about libraries. In that model I'm tracking more libraries and every library has it's own moderators. Every moderator can make categories of the books and than add books in categories (note: another library doesnt need to have same as categories of books as library where that moderator is working, every other library can have different categories of books .. ).

This picture represents how did I make it. But something is missing, think this is not good solution. I have also another tought.. To link tables "book" and "category_book" in N:M and than link "book" and "libraries" which from I can get everything I need. But, think it's also not the best solution because every library will in that moment has same categories of books.

Am I missing something or? Haven't met with this kind of problem yet so if you could help me I will be grateful

Whole design ...Note: it's not over, I can't move further beacuse of this problem

Solution

Description

I'm synthesising that these are your constraints:

  • One Book can be in MANY Category's, but only in ONE Category per Library.



  • Each Library can have ZERO or more Category's, which they do not have to "share" with other Library's.



Solution

This should all be achievable via the following structure (ignoring your wider solution space with users, borrowing, etc):

Note:  The link between library_has_category and book_in_library_category is a composite key of the library AND category keys together.

Context

StackExchange Database Administrators Q#133439, answer score: 3

Revisions (0)

No revisions yet.