When I am studying the database lecture on E/R model, it illustrates how to convert ternary relationship to binary. One way is using weak entity relationship as follows (each relationship is M:N cardinality):
ternary relationship:
convert the upper relationship with weak relationship
However, in another example:
it states in the lecture slide: "if each technician can be working on several projects and uses the same notebooks on each project, then we can decompose 3-ary relationship into binary relationships"as follows:
which I could not understand. I still kinda confused about when we should use weak entity approach and when we could just simply convert it to binary relationships as the latter one. Thanks!
Your second image illustrates a confusion between conceptual and physical data models, or a confusion between the ER and network data models. The physical implementation of the models in the first two images are the same, what differs is the interpretation of entities and relationships. The entity-relationship model supports ternary relationships, but doesn't support multiple identifying relationships for a single weak entity set. I would advise you to disregard the second image completely.
The third and fourth images illustrate a fourth normal form decomposition using ER notation. This isn't something you can do with any ternary relationship, but rather something you do when 2 or 3 independent relations have been incorrectly combined into one. For more information, I suggest you read up on Fourth Normal Form.
Related
This is a portion of a Gaming Company Chen diagram that I need to convert to a database. How do I know which entity will get the attributes LastPlayed and CreatedOn? I feel like I could make a case for either entity. It could be the LastPlayed and Created on of the Account or the Character. Is there a rule for this? TIA
The attributes you show belong to the relationship, and not either of the entities. In this case, practically speaking implementation would make them part of the (N) side of the relationship, that is, the Character entity.
The distinction between entity-attributes and relation-attributes only really matters for many-to-many relations that have to be implemented by converting the relation into its own table.
Before starting to develop anything, I made a draft of a ER diagram using Chen's notation, when developing the web page I had to change some stuff on the database, and at the end I got this ER diagram:
Between "booking" and "staff" tables I have a relational table "assign".
But between "booking" and "parts" I have this "cost" which I believe its the relational one, but I dont know how to represent it on Chen's notation diagram. Can someone give me a help? :)
Thanks.
In this physical ERD diagram, which shows how primary and foreign keys are used to implement the relationships.
From the conceptual point of view:
assign implements a many-to-many relation between staff and booking;
cost implements a many-to-many relation between booking and part that provides additional information about the combination between booking and parts.
In Chen's notation:
assign would be represented with a simple losange for relationship and a cardinality M, N.
cost would also be representad with a many-to-many relationship losange. But in addition, you'd show the relationship's attributes (e.g. quantity, cost, description) as additional ellipses connected to the relationship
You could also consider to use associative entities instead of realationships, especially for cost. It has the advantage of suggesting that there's a table behind. But it's not required in your model, unless cost could have relationships with other tables (which would be easy since there's a cost_id)
In ER diagrams, is it possible to relate two weak entities each other? If possible, how can uniquely identify records in them?
It's certainly possible. Consider the following ER diagram in which invoices are composed of lines, and receipts are decomposed into corresponding lines which are allocated to invoice lines. Multiple receipt lines can be allocated to the same InvoiceLine. It's perhaps a bit contrived but it'll serve as an example.
The InvoiceLine entity set is identified by (InvoiceNumber, LineNumber). Similarly, the ReceiptLine entity set is identified by (ReceiptNumber, LineNumber).
The determinant of a relationship between any entity sets is a combination of the determinants of the entity sets in many-roles. It doesn't matter whether the entity sets are weak or regular, or whether you have two or more entity sets involved in the relationship. In the case of 1:1 (or 1:1:1, etc) relationship, any of the entity sets involved can be used as a determinant.
In our example, ReceiptLine is the only entity set in a many-role (indicated by an N next to the Paid relationship diamond). This means the relationship is determined by the determinant of ReceiptLine, which is (ReceiptNumber, LineNumber).
If we translate our ER diagram to a tabular model, we get the following:
I translated it directly to help you see the correspondence between the diagrams, but in practice we could denormalize the Paid relationship relation into the ReceiptLine entity relation for a simpler physical model. That can only be done for relationships with a single determining entity set, so it's important that you understand the general approach first.
I'm new to database designing.
I'm trying to figure out the difference between the following two ER designs:
Assuming each record in parent tables (State and City) participates in 1:M relationship in both the ER designs, is there any functionality difference that could arise among them? Is there any situation where I might prefer one over another?
In the first case the City determines the State (City_Id->State_Id); in the second it doesn't. That's a significant difference and what matters is which of these designs more accurately describes the reality you are intending to model.
If City_Id->State_Id is correct and if these are supposed to be relational database designs then the Locality relation described by the second diagram would violate 3rd Normal Form (first diagram looks OK).
I'm new to data modelling and have started following tutorials to learn more.
I am trying to create a model for a hypothetical scenario and am struggling to validate what I have created to see if it is what would be considered a correct data model.
Essentially all im trying to do is correctly store data in a normalised form. In my scenario there are 3 types of people and each share some attributes and have one set of contact details each.
Does the below data model look feasible?
The relationship between person and one of defendant, magistrate, or staff-member is a case of the class/subclass pattern. There are two common ways of modeling this pattern in relational tables.
One way is called "Class Table Inheritance". You can find out more by visiting this tag: class-table-inheritance or by searching the web for Martin Fowler's treatment of the same subject. Your design resembles this design.
Another way is called "Single Table Inheritance", which you can also research the same way. single-table-inheritance. It's simpler, and works ok in some cases. You deal with fewer joins, but you deal with more NULLS.
Many people who go for class table inheritance also apply a technique called "Shared Primary Key". shared-primary-key. Using this technique, Defendant, Magistrate, and Staff_Member would each use a copy of person_id as the primary key. This primary key also functions as a foreign key. Shared primary key enforces the one-to-one nature of the IS-A relationships that exist in this case.
If you want to go further in data modeling, you might want to learn ER modeling as a distinct data model from the relational model. What you've done here is essentially to use ER diagramming to diagram a relational model. There's nothing wrong with that, but it obscures a whole new field of study, generally called conceptual data modeling.
If you generate an ER model at the conceptual level, you don't attempt to implement it in terms of tables. There is a diagramming convention in ER that goes under the name "generalization/specialization" that allows you to depict a class/subclass situation, while remaining silent on how it's going to be implemented.
Conceptual data models have an area of usefulness, in addition to relational data modeling. What makes conceptual data models useful is precisely the fact that they present the information requirements without stating how those requirements are going to be met.
Once you are proficient at creating conceptual data models, it's not hard to convert one of them to a relational model.
This may be more than you bargained for, but since you are taking on learning modeling, I thought I'd survey some of the field for you.