i am preparing a database schema diagram and couldn't find an abbreviation for partial key. Is there an abbreviation for partial key like FK or PK ? How can i indicate that it is a partial key?
If you are talking about making an ER diagram, and including a weak entity, then the following diagram illustrates how to display a partial key. The attribute Line Item Number is a partial key, and it has a dashed underline under it.
https://upload.wikimedia.org/wikipedia/commons/b/ba/Weak_entity_ER-example.svg
If, on the other hand, you are talking about a relational schema diagram, then it's different.
Related
When my instructor taught my SQL class about 2NF, they mentioned that it's violated if there's partial dependency - that is, when a table has a composite key and a non-key column depends only on one of the keys, and not all of the columns that comprise the PK.
If there's an entity with a single-columned PK, and there's a non-key attribute that does not depend on this PK, does it mean that it's in 2NF because the entity does not have a composite key and partial dependency is not possible, and would therefore never be violated (an attribute is only either dependent or not dependent on the PK)?
Thank you!
I'm certainly not an expert on this subject but to quote GeeksforGeeks:
"Second Normal Form applies to relations with composite keys, that is, relations with a primary key composed of two or more attributes. A relation with a single-attribute primary key is automatically in at least 2NF." (https://www.geeksforgeeks.org/second-normal-form-2nf/)
So, at least according to them, the answer is yes.
I would like to ask a question about Database Management.
So for example, I have a Relationship called 'Attends' with a few Relationship Attributes.
So when I turn this relationship into an Expanded Entity Relation Diagram, can an Attribute of this Relation turn into a Primary Key when this turns into an Entity?
Thank you in advance.
Can anybody explain the part with the multivalued attribute middleNames. How would that look in the database/tables?
The diagram isn't valid. Multivalued attributes don't have weak keys, otherwise they would be weak entities. Also, multivalued attributes don't need cardinality indicators, since they're supposed to be multivalued. Optionality can be indicated with a dashed line.
My preferred way of correcting the diagram would be to drop the mnId and middleName component attributes, like so:
Physically, this would be implemented as:
Note the composite primary key on the two columns of the MiddleNames table.
I have troubles understanding the notation on the model I was given.
I assume it means 1-n (0 included) but I do not understand why - any medication should have a dose, in addition, the keys are not nullable. So how could there be 0?
The notation is Crow's foot notation for Entity Relationship modeling (this is concerned with Entity name, Lines and boxes and names on relationships which are absent here only).
Each tool has it own way of representing some of the aspects of a data model. For example some tools use dashed/dotted lines to represent non-identifying relationship (that is the FK is allowed to change).
The diagram (boxes and lines) tells us:
R1- Each [Dose] is administrated as 0,1,...,N [Medicament(s)]
R2- Each [Medicament] Must have 1 prescribed [Dose]
NN means Not Null (this is tool dependent)
The primary key for Dose is ID
The primary key for Medicament is both [ID] and [ID Dose] (a FK from Dose).
You are correct to assume that the diagram is inconsistent. (NN) Not Nullable indicates Mandatory relationship at the [Medicament] end. Hence the (0) or little circle should not be there.
I have guessed what the relationships are in the above text, I could be wrong. That is why the data modeler should have clarified what they mean exactly otherwise the relationship could be interpreted wrong.
Here is a similar diagram using MySQL Workbench ERD Tool - No little circles or zero is shown with either types of lines:
Edit/Correction
Not being familiar with the specific tool used to represent the diagram, I assumed that both columns are part of a compound key for the child table. However, as the comment below by #KhDonen indicates, this does not have to be the case. Maybe the tool designate FK with a "key" symbol/icon even if it is not part of the PK. In which case, there would only be 1 key on each table and the diagram will be consistent.
I've sketched up the following logic data model schema:
http://img406.imageshack.us/img406/6260/proj1x.png
The problem is in the section MT payment with the general entity #mt_transac#. I can't establish a categorization relation with the category entity #mt_subscr_rebill# if it has a relation with #mt_subsrc#.
When I delete that relation it works fine. If I set up a relation between #mt_transac# and #mt_subscr_rebill# and then try to set up a relation with #mt_subscr# it also don't work.
What problem may I have in this case?
It's because the primary key of a category must be the same as that of its superclass. With the indentifying relationship shown, the primary key of the category is not equal to the primary key of the superclass.