简体   繁体   English

此图书馆管理系统ER图是否正确?

[英]Is this Library Management System ER diagram correct?

Quick question about an ER/EER Diagram. 有关ER / EER图的快速问题。

I have made this Entity Relationship Diagram, but I have been told, that there is something wrong with it by a friend. 我已经制作了这个实体关系图,但是我被告知,一个朋友有问题。 Is there something wrong with it? 这有什么问题吗?

The ER diagram is a design of a Library Management System, where a member can borrow 5 books at a time. ER图是图书馆管理系统的设计,会员每次可以借5本书。 The rest of the functionality of the system is how a normal library functions. 系统的其余功能是普通库的工作方式。

Library Management System EER 图书馆管理系统

i don't understand the utility of the relationship between the librarian and the card and i don't understand why the books are splitted in two entities. 我不了解图书管理员与卡片之间关系的实用性,也不了解为什么将图书分为两个实体。

I would do 3 entities: 我会做3个实体:

-member -会员

-card -卡

-book -书

every member has one card, every card is of one member; 每位会员都有一张卡,每张卡都属于一张会员; every member can take many books, every book can be taken by many members, 每个成员可以拿很多本书,每本书可以被很多成员拿走,

the relation between member and book create another table in the logic schema: loans. 成员与书本之间的关系在逻辑模式中创建了另一个表:借贷。 before inserting a new loan you can check if the member has alredy 5 active loans (by checking the attribute active in the loans table). 在插入新贷款之前,您可以检查成员是否有5笔有效贷款(通过检查“贷款”表中的“有效”属性)。

Your given context is incomplete for me. 您所给的上下文对我来说是不完整的。 I do not see the whole description of your problem/situation, so I will answer based on assumptions, and the experience I had during my life. 我看不到您的问题/情况的完整描述,因此我将根据假设以及我一生的经验进行回答。 So let's see... 让我们来看看...


The tino user questioned the existence of two entities, title and volume, which is something important. 提诺用户质疑两个实体的存在,标题和体积,这很重要。 Let me explain this for a moment, which will eliminate this as an error. 让我解释一下,将其消除为错误。 Previously (a time ago) we had video rental stores (I don't know if this the right name where you live, english is not my native language). 以前(前一段时间)我们有视频出租商店(我不知道这是您住的地方的正确名称,英语不是我的母语)。 Remember? 记得? We used to go there to rent VHS tapes to watch at home. 我们曾经去那里租用VHS磁带在家看。

What we rented were not films, but more copies/midia of them. 我们租的不是电影,而是更多的副本/中影。 A film will always have the same actor, director, title, etc., but a copy could have different attributes/properties, like the year that the media was manufactured, the available languages, the expiration year, among other things. 电影将始终具有相同的演员,导演,标题等,但是复制品可能具有不同的属性/属性,例如媒体的生产年份,可用的语言,有效期等。 So we had distinctly two different things. 所以我们显然有两件事。

But despite this, we have to consider whether there is a need to create two entities for persistence. 但是尽管如此,我们必须考虑是否需要创建两个实体来实现持久性。 We have to remember if we need to persist this information. 我们必须记住是否需要保留此信息。 If a copy/midia has no attributes, then it's entity should not exist, and what a user would rent really would be the movies titles. 如果副本/ midia没有属性,则它的实体不应该存在,并且用户租用的实际上是电影标题。

In your case, the relationship between volume and title, I belive, is really expressing this discrepancy. 就您的情况而言,我相信,音量和标题之间的关系确实表达了这种差异。

Let's talk about the relationship between librarian and title. 让我们谈谈馆员和头衔之间的关系。 What a librarian manages? 图书馆员管理什么? Does It manages the titles that never change and are abstract things, or the physical objects present in the library? 它管理的标题永远不变,是抽象的东西,还是库中存在的物理对象? :) :)


Finally, let's talk about the borrows relationship. 最后,让我们谈谈借入关系。 When we break down 1-N (or N-1) relationships, we always pass the primary key from the 1 side to the N side, solving the relationship to the formation of the Physical Model in a Entity-Relationship Diagram. 当我们分解1-N(或N-1)关系时,我们总是将主键从1侧传递到N侧,从而在实体关系图中解决了与物理模型形成有关的关系。

Despite this relationship here is a 0-5, to decompose it, we will not have exactly a 0-5 relationship. 尽管此关系为0-5,但要分解它,我们将不完全具有0-5关系。 We would have in anyway to pass the primary key from the two sides to the table formed by this relationship. 无论如何,我们都必须将主键从两侧传递到由这种关系形成的表。 Therefore, here we have initially a NN relationship between member and volume. 因此,这里我们最初在成员和体积之间具有NN关系。

NN relationships allow optional relations between entities. NN关系允许实体之间的可选关系。 This means we can have the zero side cardinality here. 这意味着我们可以在此处具有零边基数。 To limit the number of books that can be rented, you need to implement a restriction/constraint with SQL, or with any procedural language in your database. 为了限制可以租借的书籍数量,您需要使用SQL或数据库中的任何过程语言来实施限制/约束。 In this case, you can implement a before insert trigger. 在这种情况下,您可以实现插入前触发器。 This trigger has a duty to verify this restriction to allow or denny the completion of the operation as a whole. 此触发器有责任验证此限制,以允许或拒绝整个操作的完成。

Let it be clear that I'm not saying you should remove this notation. 明确地说,我并不是说您应该删除此表示法。 Your Conceptual Model should express it. 您的概念模型应该表达它。 But when you are decomposing, you have to remember that. 但是当您分解时,必须记住这一点。 I think you should just correct it. 我认为您应该更正它。

Remember one important rule: Relations that have attributes/properties (the attributes/properties) can only exist in NN relationships. 请记住一个重要规则:具有属性/属性(属性/属性)的关系只能存在于NN关系中。 If you have to put attributes/properties in a 1-N (or a N-1) relation, they (the attributes/properties) will always be on the N side. 如果必须将属性/属性置于1-N(或N-1)关系中,则它们(属性/属性)将始终位于N侧。 In summary, there are no N-1 (or 1-N) relationships with attributes in the relation. 总之,在该关系中不存在具有属性的N-1(或1-N)个关系。 Only NN relations can have attributes/properties. 只有NN关系可以具有属性/属性。 So be careful with this. 所以要小心。

Any questions or clarification, please comment and I will answer. 如有任何疑问或澄清,请发表评论,我会回答。

I see no reason to distinguish member and card. 我认为没有理由区分会员和会员卡。 Volume and Librarian don't have primary keys. 音量和图书管理员没有主键。 Are they supposed to be weak entities? 他们应该是弱者吗? That doesn't make sense for Librarian and Volume needs an identifier to distinguish different copies. 对于图书馆员来说这没有意义,Volume需要一个标识符来区分不同的副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM