I understand the difference between multivalued and composite attributes, but I don't know if a multivalued attribute can have further composite attributes. I think it can, but I never saw an ER diagram like that, even now that I started really looking for it, so I wanted to ask it here.
This is what I had in mind:
Or how else should I store TV shows with every episode and its title, is there a better way?
I would model Part as an entity. One way is to make it a weak entity dependent on TV Show, and distinguished by Season and Episode.
Note this diagram is incomplete without an indication of TV Show's key.
Related
I'm drawing an ER-Diagram for school. My problem are teachers and students. How would I uniquely identify those? Is there such a thing as a "composite key"? If there is, how do I mark it in the ER-diagram or should use a teacherID and studentID?
My guess is that "teachers" and "students" are entities in your diagram. If you want to identify those, you should use a unique key for each one. Say "teacherID" and "studendID" respectively.
A composite attribute on the other hand is something that looks like this:
composite attribute.
This is used for packing attributes into one attribute. I am not sure that this is what you are looking for since "teachers" and "students" are probably different entities.
I need to normalize a relation so that it is in the 1st normal form. I know how to normalize multi-valued attributes, it is just composite attributes that are giving me issues. For example, one of the composite attributes is 'Employee-Address', and as expected, it contains sub-attributes like 'House-Number', 'Street-Name' etc.
How do I normalize this? These composite attributes are not multivalued/complex i.e a single employee may only have 1 address. I also believe the 'employee-id' attribute can be used to identify all of sub-attributes of the address. Is it as simple as breaking up the composite attribute and storing each sub-attribute as its own attribute in the relation? This way all the sub-attributes would become simple, single and stored values?
Before anyone complains; this question is related to a college assignment and I've looked through the entirety of the recommended textbook(and the internet) for the answer, which I have not found. Of course, I'd like a solution to my answer, but if you'd rather give your own example that is great; any advice or pointers are much appreciated!
The only requirement of 1NF is that each attribute contain only a single "atomic" value.
If the question suggests that the address is a composite value and that each part of the address is a separate sub-value, then you should create an attribute for each sub-value.
You probably want to store each part of the address in its own attribute anyway, so you can index them and efficiently run queries like "find everyone in New York City."
is this the right way to represent this relationship which is described in text on the picture? this is in min/max notation
http://s7.postimg.org/holux2uwb/image.jpg
There is a huge lack of context here. I'll just kick a answer blindly.
In many cases while modeling data an order is usually seen as an event. I do not know exactly what is a "Bugel Card", but if it is a name of an identity such as a noun, and it has properties/attributes that must be stored, as I suspect it is the Customer, then we have two entities that have a relationship: the Customer entity, and the Bugel Card entity. The resulting connection/relationship/link forms the Order event.
If in an Order a Customer ALWAYS uses AT LEAST 1 "Bugel Card", and not more than that, then we have a cardinality (following the notation min max) of (1,1) between Customer and Bugel Card Entities, in both sides. For relationships (1,1) it takes the data modeler's discretion on which side will be set the relationship between the entities, that is, where the foreign key will go (once you decompose the Conceptual Model). It is always recommended to leave the foreign key on the side where in the future the relationship can become "many".
If you can improve a little more the context here, I can give you an answer with more accuracy (more correct), and remember:
Do not model data without a full context. When you go to an Entity Relationship Diagram starting from the Conceptual Model, you need a context, and one that is very well described. Without a full context, there is no diagram, and as a result, there is no database schema (or much less a system to use and manage).
Other than that, it is not possible to model entities without properties / attributes. Without them, an entity is nothing, because in its decomposition there will be no column to be created, and soon there will be no data to be persisted. Even if in your modeling process you let to define the attributes later you can end up confusing yourself and/or forgetting something. This is something prone to errors.
To be honest, there is no standard way of modeling data. What I have spoken so far are just data modeling tips. It is up to you what you want to do, and how you want to do.
Any questions, or anything else you need, please comment and I help you.
I've tried to look on Google about a decent explanation of weak and strong entity type, but I haven't fully understood them.
Could someone give me an example of a strong and weak entity type?
A weak entity is one that can only exist when owned by another one.
For example: a ROOM can only exist in a BUILDING. On the other hand, a TIRE might be considered as a strong entity because it also can exist without being attached to a CAR.
Just to play with it, question is strong entity type and answer is weak. Question is always there, but an answer requires a question to exist.
Example: Don't ask 'Why?' if Your Dad's a Chemistry Professor
A weak entity is the entity which can't be fully identified by its own attributes and takes the foreign key as an attribute (generally it takes the primary key of the entity it is related to) in conjunction.
Examples
The existence of rooms is entirely dependent on the existence of a hotel. So room can be seen as the weak entity of the hotel.
Another example is the
bank account of a particular bank has no existence if the bank doesn't exist anymore.
A company insurance policy insures an employee and any dependents, the DEPENDENT cannot exist without the EMPLOYEE; that is, a person cannot get insurance coverage as a dependent unless the person is a dependent of an employee.DEPENDENT is the weak entity in the relationship "EMPLOYEE has DEPENDENT"
Strong entity
It can exist without any other entity.
Example
Customer(customerid, name, surname)
Weak entity
It depends on a dominant entity, and it cannot exist without a strong entity.
Example
Address(addressid, addressName, customerid)
Weak entity exists to solve the multi-valued attributes problem.
There are two types of multi-valued attributes. One is the simply many values for an objects such as a "hobby" as an attribute for a student. The student can have many different hobbies. If we leave the hobbies in the student entity set, "hobby" would not be unique any more. We create a separate entity set as hobby. Then we link the hobby and the student as we need. The hobby entity set is now an associative entity set. As to whether it is weak or not, we need to check whether each entity has enough unique identifiers to identify it. In many opinion, a hobby name can be enough to identify it.
The other type of multi-valued attribute problem does need a weak entity to fix it. Let's say an item entity set in a grocery inventory system. Is the item a category item or the actually item? It is an important question, because a customer can buy the same item at one time and at a certain amount, but he can also buy the same item at a different time with a different amount. Can you see it the same item but of different objects. The item now is a multi-valued attribute. We solve it by first separate the category item with the actual item. The two are now different entity sets. Category item has descriptive attributes of the item, just like the item you usually think of. Actual item can not have descriptive attributes any more because we can not have redundant problem. Actual item can only have date time and amount of the item. You can link them as you need. Now, let's talk about whether one is a weak entity of the other. The descriptive attributes are more than enough to identify each entity in the category item entity set. The actual item only has date time and amount. Even if we pull out all the attributes in a record, we still cannot identify the entity. Think about it is just time and amount. The actual item entity set is a weak entity set. We identify each entity in the set with the help of duplicate prime key from the category item entity set.
./Database/DataModels/RelationalDataModel/WeakEntity
It probably can be written in two factors:
DEPENDENCE: Depends on the existence of an identifying entity set (total, one-to-many relationship).
IDENTIFICATION: Does not have a primary key. It has a partial key (or discriminator). It needs to use the primary key of another table for identification.
If we would think of a database holding questions and answers, then the questions would be the strong entity and the answers would be the weak entity.
So, Question (id, text) and Answer (number, question_id, text) would be our tables. But why is the Answer's table a weak entity?
Dependence to the question table. Every answer is connected to one question (assumption) and so it cannot be on its own. That is why we have people who ask one question and answer it themselves so that they can help other people and get some extra likings.
Identification from the primary key of the question. One would not be able to identify an answer (assuming that its id is a number identifier) because a question might be answered by answers whose identifier might exist in other questions too. Primary key of the answer table: (number, question_id).
Weak entities are also called dependent entities, since it's existence depends on other entities. Such entities are represented by a double outline rectangle in the E-R diagram.
Strong entities are also called independent entities.
After browsing search engines for a few hours I came across a site with a great ERD example here: http://www.exploredatabase.com/2016/07/description-about-weak-entity-sets-in-DBMS.html
I've recreated the ERD. Unfortunately they did not specify the primary key of the weak entity.
If the building could only have one and only one apartment, then it seems the partial discriminator room number would not be created (i.e. discarded).
Weak Entity Type:
An entity whose instances cannot exits without being linked with instances of some other entity is called weak entity type. It cannot exist independently.
For example: Our PC is depend on us it will not open or close with its own.
Strong Entity Type:
An entity whose linked to the instances of any other entity type is called strong entity type. It can exit independently.
For example: A person can do every thing can go everywhere and use ever thing
A data object that can exist without depending upon the existence of another data object is known as Strong Data Object.
First Strong/Weak Reference types are introduced in ARC. In Non ARC assign/retain are being used.
A strong reference means that you want to "own" the object you are referencing with this property/variable. The compiler will take care that any object that you assign to this property will not be destroyed as long as you points to it with a strong reference. Only once you set the property to nil, the object get destroyed.
A weak reference means you signify that you don't want to have control over the object's lifetime or don't want to "own" object. The object you are referencing weakly only lives on because at least one other object holds a strong reference to it. Once that is no longer the case, the object gets destroyed and your weak property will automatically get set to nil.
The most frequent use cases of weak references in iOS are for IBOutlets, Delegates etc.
For more info Refer : http://www.informit.com/articles/article.aspx?p=1856389&seqNum=5
There are couples of questions around asking for difference / explanation on identifying and non-identifying relationship in relationship database.
My question is, can you think of a simpler term for these jargons? I understand that technical terms have to be specific and unambiguous though. But having an 'alternative name' might help students relate more easily to the concept behind.
We actually want to use a more layman term in our own database modeling tool, so that first-time users without much computer science background could learn faster.
cheers!
I often see child table or dependent table used as a lay term. You could use either of those terms for a table with an identifying relationship
Then say a referencing table is a table with a non-identifying relationship.
For example, PhoneNumbers is a child of Users, because a phone number has an identifying relationship with its user (i.e. the primary key of PhoneNumbers includes a foreign key to the primary key of Users).
Whereas the Users table has a state column that is a foreign key to the States table, making it a non-identifying relationship. So you could say Users references States, but is not a child of it per se.
I think belongs to would be a good name for the identifying relationship.
A "weak entity type" does not have its own key, just a "partial key", so each entity instance of this weak entity type has to belong to some other entity instance so it can be identified, and this is an "identifying relationship". For example, a landlord could have a database with apartments and rooms. A room can be called kitchen or bathroom, and while that name is unique within an apartment, there will be many rooms in the database with the name kitchen, so it is just a partial key. To uniquely identify a room in the database, you need to say that it is the kitchen in this particular apartment. In other words, the rooms belong to apartments.
I'm going to recommend the term "weak entity" from ER modeling.
Some modelers conceptualize the subject matter as being made up of entities and relationships among entities. This gives rise to Entity-Relationship Modeling (ER Modeling). An attribute can be tied to an entity or a relationship, and values stored in the database are instances of attributes.
If you do ER modeling, there is a kind of entity called a "weak entity". Part of the identity of a weak entity is the identity of a stronger entity, to which the weak one belongs.
An example might be an order in an order processing system. Orders are made up of line items, and each line item contains a product-id, a unit-price, and a quantity. But line items don't have an identifying number across all orders. Instead, a line item is identified by {item number, order number}. In other words, a line item can't exist unless it's part of exactly one order. Item number 1 is the first item in whatever order it belongs to, but you need both numbers to identify an item.
It's easy to turn an ER model into a relational model. It's also easy for people who are experts in the data but know nothing about databases to get used to an ER model of the data they understand.
There are other modelers who argue vehemently against the need for ER modeling. I'm not one of them.
Nothing, absolutely nothing in the kind of modeling where one encounters things such as "relationships" (ER, I presume) is "technical", "precise" or "unambiguous". Nor can it be.
A) ER modeling is always and by necessity informal, because it can never be sufficient to capture/express the entire definition of a database.
B) There are so many different ER dialects out there that it is just impossible for all of them to use exactly the same terms with exactly the same meaning. Recently, I even discovered that some UK university that teaches ER modeling, uses the term "entity subtype" for the very same thing that I always used to name "entity supertype", and vice-versa !
One could use connection.
You have Connection between two tables, where the IDs are the same.
That type of thing.
how about
Association
Link
Correlation