Тёмный

Database Design for a Library Management System 

Database Star
Подписаться 62 тыс.
Просмотров 74 тыс.
50% 1

Опубликовано:

 

15 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 88   
@DatabaseStar
@DatabaseStar 2 года назад
If you want the SQL to create the tables in this design, you can refer to the link in the description. A few comments below had asked for this.
@houstonfirefox
@houstonfirefox 3 года назад
For those wondering, the primary key 'ID' on book table is used so that duplicate book names can be represented, with other fields to help the user differentiate which they are looking at.
@DatabaseStar
@DatabaseStar 3 года назад
Good point! And also if the book name or anything else changes it can be updated without impacting any links to other tables.
@houstonfirefox
@houstonfirefox 3 года назад
@@DatabaseStar Also a good point! Primary key changes are to be avoided at all costs. Using a surrogate key as is done here is certainly preferable to using possibly-changing data in the key. Very nice work sir!
@vinny142
@vinny142 3 года назад
@@houstonfirefox " Primary key changes are to be avoided at all costs." That's a bit strong because you can define ON UPDATE CASCADE on the relations and any change in the PK value will be automatically passed to the related tables. This may result in an unexpected or undesirable amount of tuple-writes, but that is a different matter. You cannot break your data by changing a PK value, the "MS" bit in the RDBMS will not let you.
@houstonfirefox
@houstonfirefox 3 года назад
@@vinny142 True and for the most part, I agree. However, many of the so-called 'professional' pieces of software I deal with perform integrity-checking on the front end (application) and inconsistent/little-to-any on the back end (database side). As such, there are many times where there is no protection against a PK change in the primary table resulting in a lot of 'orphaned' data in the related tables. At our company we recently saw this happen to our $250,000+/year CRM system which created quite a nightmare to sort out (and retroactively update). Developers are a whole other story as you know hahaha. Of course, one of the downsides of a surrogate key is when transporting the data between databases using a script. If the 'auto-id' or 'identity' is not disabled prior to the script running then it may result in a renumbering of the surrogate key and all of the fun that ensues after that. Thanks for the reply! I enjoy the discussion!
@IAmPhysics1
@IAmPhysics1 2 года назад
For the fine system, one could apply a bit of accounting knowledge and keep it all in one table. To do this, I would structure the fines table like this: * (PK) id * (FK) Member_id * Loan_id //Remove FK constraint. Payments can be independent of a specific loan ID. * Fine_date * Fine_type //This is the first big change. Define whether the fine is the initial fine, or compounding interest. Some libraries do that. * Fine_debit //For increases to the fines owed, both initial and interest. * Fine_credit //For decreases to the fines owed. This would essentially structure the fines table to be like an accounting ledger, which is a tried and true layout for auditing any sort of money movement.
@DatabaseStar
@DatabaseStar 2 года назад
Great idea! This does have the benefits you mentioned, such as increasing and decreasing the fine amount.
@alejandrocarmena8767
@alejandrocarmena8767 Год назад
Hi, very insightful video :) just one question. Since "member_id" is already found in "loan", why is it duplicated in table "fine"?
@DatabaseStar
@DatabaseStar Год назад
Thanks! Good question. I think you're right, you don't actually need the member_id in the fine table. You can find the member that it is for by looking at the related loan record. And having it in the fine table, in my design, leaves it open for the member ID to be different which could be different.
@karanpaul5525
@karanpaul5525 2 года назад
How can we use this final ERD design to create the tables in SSMS? I mean how to code just by observing the final ERD?
@rajatssphere8781
@rajatssphere8781 2 года назад
Yes! Exactly I am still figuring out how to write the create and alter table queries just by looking at the final design. It's so confusing
@DatabaseStar
@DatabaseStar 2 года назад
Great question! I'll add the code for this to this video (perhaps as a comment with a link to it). In short, you write a range of Create Table statements, but I can see how it can be confusing.
@karanpaul5525
@karanpaul5525 2 года назад
@@DatabaseStar thanks a lot 🙏
@DatabaseStar
@DatabaseStar 2 года назад
@Karan Paul I've added a link to the description with the SQL code to create the tables. Hope that helps!
@Modi_In_Canada
@Modi_In_Canada Год назад
Let's say I have 10 copy of a book.. How can I get status of each book?
@DatabaseStar
@DatabaseStar Год назад
You could use a combination of the loan table and the book table to determine how many books are currently loaned out. This design doesn't track each individual copy of the book, but you could tell from this design how many of the 10 books are currently loaned out.
@syedburhanalishah1631
@syedburhanalishah1631 Год назад
Very well done Sir. It would be beneficial if you could show Identifying and Non-Identifying relations in the ERD too. I still find it difficult to grasp. Or if you could please make a video about Strong & Weak Entities and Identifying & Non-Identifying relations.
@DatabaseStar
@DatabaseStar Год назад
Thanks! I don't often come across those concepts when creating ERDs.
@syedburhanalishah1631
@syedburhanalishah1631 Год назад
@@DatabaseStar Is that because we are now using surrogate keys in every table ?
@theuntrainedsinger1185
@theuntrainedsinger1185 10 месяцев назад
Why didn't you create a table for each copy of book? I know you didn't put it in requirements but why.
@DatabaseStar
@DatabaseStar 10 месяцев назад
Good point, and that is something I should have created, so we can track each copy of the book.
@dishasolanki56
@dishasolanki56 2 года назад
Why fine_payment is not associated with loan ? If there is something like "Find top10 books for which max fine has been paid", with the current design that is not possible.
@DatabaseStar
@DatabaseStar 2 года назад
I chose not to relate fine_payment to loan because the fine table is already related to loan, and the fine payments could be recorded independently and be for one or many loans. But it would be just as valid to relate fine_payment to fine, which would be done by putting the fine.id into the fine_payment table. You could "find the top 10 books for which max fine has been paid" by joining through the member table to the fine_payment table to see the payments, but yes it would be a bit trickier.
@mehmetyasirsaher
@mehmetyasirsaher Год назад
Hi sir! Thanks for the video it really helped me and I learn a lot of basics about SQL from this project. However, I failed to create queries. Could you help me? I need some examples. Thank you for everything.
@DatabaseStar
@DatabaseStar Год назад
Good to hear! Sure, you can check out the SQL Roadmap mentioned in the description to see how to start creating SQL queries.
@Photonsr
@Photonsr 3 месяца назад
Is this database normalised to 1NF, 2NF and 3NF?
@DatabaseStar
@DatabaseStar 3 месяца назад
Yes it should be normalised to 3NF.
@MuhammadHuzaifaKhan-o3s
@MuhammadHuzaifaKhan-o3s 11 месяцев назад
How do I know that which fines are pending for the specific member?
@DatabaseStar
@DatabaseStar 11 месяцев назад
You can select from the fine table and filter on a specific member ID. There isn't a way to link the specific payment to the specific fine, but you can calculate a total to see the outstanding balance.
@m_forever7
@m_forever7 3 года назад
Is there any coding available for this database ? I need it for a project.
@DatabaseStar
@DatabaseStar 3 года назад
Hi, you can use the final design at the end of the video to create the tables. You can write a range of Create Table statements to create the tables in your database.
@DatabaseStar
@DatabaseStar 2 года назад
@Meenakshi - I've added a link to the description with the SQL code to create the tables. Hope that helps!
@rajatssphere8781
@rajatssphere8781 2 года назад
Can you provide the code for this database...only just for few tables because idk how to do that.
@DatabaseStar
@DatabaseStar 2 года назад
Good idea Rajat, I'll add the code (as mentioned in another comment).
@DatabaseStar
@DatabaseStar 2 года назад
@Rajat - I've added a link to the description with the SQL code to create the tables. Hope that helps!
@trupti6251
@trupti6251 Год назад
Is it correct if we have a status in fine_payment which will contain whether the payment is due or paid ?
@DatabaseStar
@DatabaseStar Год назад
Yes that can work
@estergreis7684
@estergreis7684 2 года назад
What if there is a rule that you can't loan more than two books at the same time and if you want to loan another book you have to return one of the two books you have already loaned, how can we add this in the Entity Relationship Diagram?
@DatabaseStar
@DatabaseStar 2 года назад
Good question. You could try to add a constraint for loans, but I don't think a constraint could handle that kind of logic. There are a few ways you could do this: a database trigger to check the table, a function or stored procedure that does the loan process and includes this logic, or adding the logic into the application code. I would suggest either a stored procedure on the database or in the application code.
@azqaf4287
@azqaf4287 2 года назад
Hello sir. I am sorry if i make mistake writing in english. Sir i want to add book with its author at the same time but i do not know how to do this. Can you please give me tip
@DatabaseStar
@DatabaseStar 2 года назад
You can insert a record into both tables if you like.
@tylercondon3453
@tylercondon3453 2 года назад
Very informative video! Thanks so much!
@DatabaseStar
@DatabaseStar 2 года назад
Glad it was helpful!
@Bimmerish
@Bimmerish Год назад
Hello, I have some questions how i can send a direct message to you?
@DatabaseStar
@DatabaseStar Год назад
Hey, I have a contact form on my website that sends me an email. It’s at www.databasestar.com
@IrfanRafiq-os3ed
@IrfanRafiq-os3ed 3 месяца назад
please share some queries to get data from this library database
@DatabaseStar
@DatabaseStar 3 месяца назад
I can add some in the future.
@El-Ge
@El-Ge 2 года назад
Where is the book's code which is different with book's ID, for in all libraries each books has its own book code.
@DatabaseStar
@DatabaseStar 2 года назад
Good point. This can also be added to the book table as a separate field.
@sahilsiddiqui3210
@sahilsiddiqui3210 Год назад
what about the librarian , library having differnt branch
@DatabaseStar
@DatabaseStar Год назад
Good ideas. Yes you can add those to this design.
@PeterJoel-t6x
@PeterJoel-t6x 11 месяцев назад
How can I create my own database library
@DatabaseStar
@DatabaseStar 11 месяцев назад
What do you mean? You can follow this video as an example
@kumarraot
@kumarraot 2 года назад
Input: You can have check constraint on the fields like status, category etc. NO need to maintain another table for same. ALTER TABLE [TableName] ADD CONSTRAINT my_constraint CHECK (Status = 'in stock' OR status = 'borrowed')
@DatabaseStar
@DatabaseStar 2 года назад
Yeah that’s true, you can use a check constraint. They are harder to edit or add new values to as you need to run an Alter statement instead of just editing table data. But if the possible values rarely change then it’s not that much of an issue and a check constraint would be better.
@tommurd3116
@tommurd3116 Год назад
Do you have dfd for this system?
@DatabaseStar
@DatabaseStar Год назад
No not for this example
@rhythmrhy1380
@rhythmrhy1380 Год назад
Excellent job
@DatabaseStar
@DatabaseStar Год назад
Thanks!
@hhhh11517
@hhhh11517 2 года назад
is all the ids in the diagram same.
@DatabaseStar
@DatabaseStar 2 года назад
Yes I believe they are
@ugbatmagnai3567
@ugbatmagnai3567 3 года назад
Do we need create entity of library staff?
@DatabaseStar
@DatabaseStar 3 года назад
If you'd like it in the database, you can create it. It could be a good enhancement if you want to capture information about library staff.
@Mzounalqarni
@Mzounalqarni 2 года назад
Can you make a video to make a ER diagram for this system ?
@DatabaseStar
@DatabaseStar 2 года назад
What do you mean by making an ER diagram? Isn’t that what this video is?
@Mzounalqarni
@Mzounalqarni 2 года назад
@@DatabaseStar ER diagram showing the relationship and entities
@DatabaseStar
@DatabaseStar 2 года назад
Hi Nine, this video actually shows you how to make an ER diagram for this system. At the end of the video is the final ERD, and there's a link to the ERD in the description (a PNG file)
@banelethabede4871
@banelethabede4871 2 года назад
The link to SQL code is dead someone help me get the code please
@DatabaseStar
@DatabaseStar 2 года назад
What happens when you click the link? I just tried it and it works. Here's the link: dbshostedfiles.s3.us-west-2.amazonaws.com/dbs/library_management_create.sql
@banelethabede4871
@banelethabede4871 2 года назад
@@DatabaseStar Thank you, it kept loading after a while it gave an error saying host not available
@carthai4590
@carthai4590 3 месяца назад
i'm a fan of yours
@DatabaseStar
@DatabaseStar 3 месяца назад
Thanks!
@manyabhutani8235
@manyabhutani8235 2 года назад
what about identifying relations?
@DatabaseStar
@DatabaseStar 2 года назад
What do you mean by identifying relations?
@Ahmad-ww4ue
@Ahmad-ww4ue 2 года назад
@@DatabaseStar I guess she meant relationships between the tables, i.e. parent/child or 1-to-1, one-to-many, or many-to-many.
@ellaabbasi8723
@ellaabbasi8723 3 года назад
Why loan_fine relationship is one-to-many?
@DatabaseStar
@DatabaseStar 3 года назад
It’s because there could be multiple fines for one loan. That’s just one way to design it, you could have a one to one relationship or another way.
@puneetyadav492
@puneetyadav492 4 месяца назад
Thank you
@DatabaseStar
@DatabaseStar 4 месяца назад
You're welcome
@nadaawad9828
@nadaawad9828 Год назад
Thanks 💖
@DatabaseStar
@DatabaseStar Год назад
You’re welcome!
@neuroglide6854
@neuroglide6854 2 года назад
Just for the record man, the way you speak sucks....It is not loud enough, super soft and you have this disappearing end, which makes listening to you frustrating...
@DatabaseStar
@DatabaseStar 2 года назад
Thanks for the feedback! Since recording this video I've worked to improve my audio quality (new microphone, better editing), so I hope the newer videos have better quality. What do you mean by "disappearing end"?
@stupid-handle
@stupid-handle Год назад
I liked the video a lot. Thanks so much for the time you put on making these, as it might be a hard labour. Being that said, I expected to see some follow up video(s) about querying this database to meet the proposed goals, maybe introducing some function(s) to automate the tasks at hand, etc. But it's ok.
@DatabaseStar
@DatabaseStar Год назад
Thanks! Good idea on a follow up video. I hadn't considered that, but I can make a video about that for this database in the future.
@stupid-handle
@stupid-handle Год назад
Thanks, either for this or some other one. The good thing is one gets a full example, not only about the design, but also about using it for "real". One thing is understanding joins, or other facilities the language provides, and some other is how it all applies to real-life or real-time use. For example, I opted for trying to implement the digikey's store to begin with, and even though I could write the schema following your logic and it makes perfect sense to me, I'm really having a bad time extracting all the data to fill in the html elements (which can probably be done in a single query by using joins), let alone even figuring out what I should do when the user clicks on an html element or another.
Далее
Database Design for a Hotel Management System
12:14
Просмотров 14 тыс.
Million jamoasi - Amerikaga sayohat
12:37
Просмотров 220 тыс.
Logical Database Design and E-R Diagrams
32:23
Просмотров 376 тыс.
7 Database Design Mistakes to Avoid (With Solutions)
11:29
Database Design Tutorial
17:10
Просмотров 955 тыс.
Microservices with Databases can be challenging...
20:52
Million jamoasi - Amerikaga sayohat
12:37
Просмотров 220 тыс.