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.
Related
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."
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.
I want to know whether I can connect a ternary relationship to a another entity without that forming an n-ary relationship. To describe in terms of tables, I want to get a reference in the ternary relationship table to another (entity's) table.
Conceptually and generally, yes.
It can reasonably be called a binary relationship between the other and the associative entity, and a 4-way relationship among/over the other and the entities that form the associative entity.
But what exactly your terms mean and how you are allowed to design depends on your particular information modeling method and/or tool.
Eg your method/tool might or might not require that you add an identifier to an association type and use that in other tables rather than just the 3 columns.
Eg E-R Modeling distinguishes between "entity" and "relationship" types (each type having a corresponding table with other columns for "properties"). But this isn't actually necessary in informaton modeling since an "entity" could just be considered a 1-ary "association" and a "property" could just be considered an "entity". (Is a "marriage" a "relationship" between spouses and/or an "entity" with an anniversary and/or "property" of a family or wedding?) Also, any columns that are unique in any table or query result identify some "thing" type whether or not it is one of the base (non-associative or associative) "entity" types.
(More here.)
Here's a DB schema:
users(id, name);
items(id, user, name), user is a foreign key
tags(item, name), item is a foreign key
Based on that schema:
each item has one user (one to one relationship)
each item may have multiple tags (one to many relationship)
Pretend you are a record from items.
What term would you use to refer to a record from users, based on your relationship? Would you call it a "one to one relative" or something else?
Similarly, what term would you use to refer to a bunch of tags? Would you call them "one to many relatives" or something else?
If the class is specific to items, you could call the user for an item an "owner", and the tags simply the "tags".
If the class is a generic record handler (e.g. an active record or data mapper), there aren't many English words that would apply. "Relative" and "relatives" are two, though they may not add much meaning to method names. There's a functional relationship between items and users, where the item is the argument/input and the user is the value/output, but these terms are poor descriptions. I suspect most any generic terms will suffer the same problem of having low descriptive power.
Taking inspiration from the term codomain (of a function), you could try using the prefix "co-".
In the OO world, the relationship between items and tags is an aggregation, which suggests that you could refer to the tags as an "aggregate" in method names.
I would say "the corresponding record".
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