Entity relationship modeling and normalization

Entity Relationship Diagrams and Normalization by Marlon Millamina on Prezi

entity relationship modeling and normalization

Outline Data Modeling: Big picture E-R Model Table Normalization Attributes types Relationships connectivity, cardinality strength, participation, degree Entities. It helps give the high-level view of the whole database, while normalization is more ER Data models design a whole database using entities and relationships. Database, Data modeling, Design Database, DBMS, SQL, ER modelling, Normalisation, Database management. Transform a model into physical database design. Learn normalization technique for designing tables.

A functional dependency in which the determinant contains more than one attribute usually represents a many-to-many relationship, which is more addressed through higher normal forms. The notion of having a composite entity identifier is not very common, and often times is a matter of expediency, rather than good entity structure or design. Transitive dependency in an entity type occurs if non entity identifier attributes have dependency among themselves.

For example, consider the modified Student entity type as shown in Figure 4. Figure 4 In this entity type, suppose there is a functional dependency BuildingName?

Entity-Relationship (ER) Models — CSCI Database Systems 1 documentation

Fee dependency implies that the value assigned to the Fee attribute is fixed for distinct BuildingName attribute values. In other words, the Fee attribute values are not specific to the SID value of a student, but rather the BuildingName value. The entity instance of transitive dependency is shown in Figure 5.

Figure 5 Multi-valued dependency equivalency in ERD occurs when attributes within an entity instance have more than one value. This is a situation when some attributes within an entity instance have maximum cardinality of N more than 1. When an attribute has multiple values in an entity instance, it can be setup either as a composite key identifier of the entity type, or split into a weak entity type.

For example, consider the following entity type Student Details as shown in Figure 6. The composition of entity identifier is due to the fact that a student has multiple MajorMinor values along with being involved in multiple activities. The multi-valued dependency affects the key structure.

entity relationship modeling and normalization

This means that a SID value is associated with multiple values of MajorMinor and Activity attributes, and together they determine other attributes. The entity instance of Student Details entity type is shown Figure 7. Each normal form rule and its application is outlined. First Normal Form 1NF The first normal form rule is that there should be no nesting or repeating groups in a table.

Normalizing with Entity Relationship Diagramming

Now an entity type that contains only one value for an attribute in an entity instance ensures the application of first normal form for the entity type. So in a way any entity type with an entity identifier is by default in first normal form.

For example, the entity type Student in Figure 2 is in first normal form. Second Normal Form 2NF The second normal form rule is that the key attributes determine all non-key attributes. A violation of second normal form occurs when there is a composite key, and part of the key determines some non-key attributes.

The second normal form deals with the situation when the entity identifier contains two or more attributes, and the non-key attribute depends on part of the entity identifier. For example, consider the modified entity type Student as shown in Figure 8. The entity type has a composite entity identifier of SID and City attributes. Figure 8 An entity instance of this entity type is shown in Figure 9.

Now, if there is a functional dependency City?

entity relationship modeling and normalization

Status, then the entity type structure will violate the second normal form. Figure 9 To resolve the violation of the second normal form a separate entity type City with one-to-many relationship is created as shown in Figure The relationship cardinalities can be further modified to reflect organizational working. In general, the second normal form violation can be avoided by ensuring that there is only one attribute as an entity identifier. This normal form is violated when there exists a dependency among non-key attributes in the form of a transitive dependency.

For example consider the entity type Student as shown in Figure 4. In this entity type, there is a functional dependency BuildingName? Fee that violates the third normal form. Transitive dependency is resolved by moving the dependency attributes to a new entity type with one-to-many relationship.

In the new entity type the determinant of the dependency becomes the entity identifier.

entity relationship modeling and normalization

The resolution of the third normal form is shown in Figure The Boyce-Codd normal form rule is that every determinant is a candidate key. Even though Boyce-Codd normal form and third normal form generally produce the same result, Boyce-Codd normal form is a stronger definition than third normal form.

Every table in Boyce-Codd normal form is by definition in third normal form. Boyce-Codd normal form considers two special cases not covered by third normal form: Part of a composite entity identifier determines part of its attribute, and a non entity identifier attribute determines part of an entity identifier attribute. These situations are only possible if there is a composite entity identifier, and dependencies exist from a non-entity identifier attribute to part of the entity identifier.

For example, consider the entity type StudentConcentration as shown in Figure The entity type is in third normal form, but since there is a dependency FacultyName? MajorMinor, it is not in Boyce-Codd normal form.

Figure 12 To ensure that StudentConcentration entity type stays in Boyce-Codd normal form, another entity type Faculty with one-to-many relationship is constructed as shown in Figure Figure 13 Fourth Normal Form 4NF Fourth normal form rule is that there should not be more than one multi-valued dependency in a table. For example, consider the Student Details entity type shown in Figure 6.

Now, during requirements analysis if it is found that the MajorMinor values of a student are independent of the Activity performed by the student, then the entity type structure will violate the fourth normal form. To resolve the violation of the fourth normal form separate weak entity types with identifying relationships are created as shown in Figure The StudentFocus and StudentActivity entity types are weak entity types. It is now presumed that the Student entity type has the functional dependency SID?

Due to the similarity in the notion of an entity type and a relation, normalization concepts when explained or applied to an ERD may generate a richer model.

Also, such an application enables a better representation of user working requirements. This application now results in the specification of additional guidelines for refining an ERD.

These guidelines can be stated as follows: There should be only one dependency in each entity type where the determinant is the entity identifier. There should not be any additional dependency among the non entity identifier attributes.

Any such additional dependency should be represented by a new entity type with one-to-many relationship. If there is a composite entity identifier of three or more attributes it should be ensured that there is only one multi-valued dependency among them. Do the set of all students and staff make up all the people we will store in the database?

Are the people who are not student or staff?

entity relationship modeling and normalization

The key defines the meaning of the entity. If for a class, the key is the code of the class i. CSCIthen we are talking about a catalog class. If for a class, the key is the CRN, then we are talking about a specific section of a class that is offered at a specific semester and year.

If no natural key exists, then it is reasonable to make up an arbitrary one. All relationships must be marked with referential integrity and cardinality constraints which are crucial in converting them to the relational model. The model must satisfy all the requirements of the given problem, no more no less.

Faitfulness The model must not contain unnecessary information: Simpler models are better: An entity that contains only key attributes may be converted to an attribute.

Attributes that do not depend solely on the key of the entity must be put in a separate entity. Unless there are other relationships specifically connecting to the email entity.

Suppose the following functional dependency holds: We can create a new entity with attributes: Here is a better model for the same attributes: The key of the entity is the combination of the keys of all the supporting entities and the key of the weak entity.

entity relationship modeling and normalization

All attributes of the weak entity are placed in the relation for the weak entity. Employees Id, firstname, lastname, street, city, state, zip Key: For each A, there is a single B. Then store the B for each A as an attribute: A keyforA, attributesforA, keyforB Key: A keyforA, attributesforA Key: We can add the key for Department in Employee Employee List the key of that department.