










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Making an ERD in MMA Course Year 2025-2026
Typology: Lecture notes
1 / 18
This page cannot be seen from the preview
Don't miss anything!











Second Trimester AY 2024-
At the end of this module, the students should be able to:
A core principle of the database approach is data abstraction , which simplifies data by hiding storage and organization details while emphasizing essential features. This allows users to view data at their preferred level of complexity. A data model is a logical blueprint for a database. It simplifies database design by defining core elements like entities, attributes, relationships, and constraints, which a DBMS uses. Data models provide basic retrieval/update operations, and are essential for achieving this abstraction.
Data models, which describe database structure, vary depending on the concepts they utilize. While the network, hierarchical, and relational models are the most common, other data models exist to address specific real-world scenarios. We will focus on High-level or Conceptual data models that represent real-world concepts using entities, attributes, and relationships. Entities are objects like "employee" or "project." Attributes are their properties, such as "employee name" or "salary." Relationships show how entities connect as an "employee works on a project" relationship.
Conceptual modeling is crucial for successful database application design. A database application includes the database itself and the programs that manage queries and updates. For instance, a Student Enrollment application uses programs to handle course enlisting and schedule finalization, providing user-friendly interfaces for students. Designing, implementing, and testing these programs is a significant part of the application. While traditionally seen as software engineering, database design and software engineering are closely linked and often integrated in modern software design tools.
Figure 1 provides a simplified overview of the database design process, which emphasizes the use of high-level conceptual database models.
Figure 2: Graphical representations of an entity.
Entity Types
Attribute Types
They are used to connect related information between entities. It is the association among different entities.
The number of entities involved in a relationship is its degree. A relationship type can be degree two (binary) or degree three (ternary).
Relationships form relationship types between entity types (e.g. Relationship type Enrolls between entity types Student and Subject).
A relationship may be characterized by attributes in the same way as an entity (e.g. date and quantity in the Order relationship type).
A Relationship can be: ● A strong relationship if it connects two independent entities (strong entities). It is represented by a single diamond. ● A weak relationship if it connects a weak entity to its identifying strong entity. It is represented by a double diamond.
Figure 4: Binary relationship between the Student and Subject entities. An example of a strong relationship as well.
Figure 5: Ternary relationship between the Teacher, Subject, and Student entities. Another example of a strong relationship.
Figure 5: Binary relationship between a strong entity (Employee) and a weak entity (Dependent).An example of a weak relationship as well. The attribute Name of the Dependent is a partial key.
Figure 6: Binary relationship between a Customer entity and a Product entity. The relationship has an attribute Date and Quantity.
ER Constraints ER Constraints define rules for how entities relate to each other:
Partial Key Attribute
Composite Attribute
Participation Constraints (Total Participation of E2 in R)
Cardinality Constraints (Cardinality Ratio 1: N for E1:E2 in R)
NOTE: Different notation systems exist for ER diagrams. Please use the notation from this handout for the assignments.
Simple Example A subject is defined by a unique subject ID, a subject title, and the number of units. Crucially, a course must always have students enrolled. Each student is uniquely identified by a student number, and their name is further specified by first name, middle name, and last name. Additional student information includes their birthday, from which their age is derived, and their contact numbers, which can have multiple entries. A student cannot be considered a student unless they are enrolled in at least one subject. A single subject can have multiple students, and conversely, a student can be enrolled in different subjects.
The relational model is a formal, logical data model. It was proposed by Codd in 1970 [1] and offers very strong theoretical backing through relational algebra.
The relational model is the base of relational DBMSes (PostgreSQL, MySQL, SQL Server, etc.) and is implemented through SQL. It is also the base of the normalization theory.
The relational model structures databases as a collection of relations (not relationships), which are conceptually similar to tables. It organizes database elements into tables, where each table represents a set of data, enabling various operations to be performed on that data.
Components of a Relational Table
Figure 7: A database that contains three tables.
Properties of a Table ● It has a name that is distinct from all other tables in the database. ● There are no duplicate rows; each row is distinct. ● Entries in columns are atomic, which means that the table does not contain repeating groups or multivalued attributes. ● Entries from columns are from the same domain based on their data type including: ○ Number (numeric, integer, float, etc.) ○ Character (string) ○ Boolean (true or false) ● Operations combining different data types are not allowed. ● Each attribute has a distinct name. ● The sequence of columns is insignificant. ● The sequence of rows is insignificant
Keys ● A superkey is any set of attributes {Ai}i∈{0..n} of a relation where no two tuples can have the same set of values for these attributes. i.e. a superkey is any set of attributes that uniquely identifies tuples. ● A candidate key is a minimal superkey, i.e. any superkey so that there is no smaller superkey. ● The primary key of a relation is a particular candidate key used to identify tuples. The primary key is represented by underlining its attributes. Every relation must have a primary key. ● A foreign key is an attribute that references the primary key of another relation.
Figure 9: Pnumber and Dnumber are the primary keys of their respective tables. Dnum is a foreign key in the Project table that references Dnumber from the Department table.
Integrity Constraints A database schema is the sum of the relation schemas and integrity constraints or the rules to make sure the database is in a coherent state. The different kinds of constraints are: ● Entity Integrity Constraint. specifies that a primary key’s value cannot be NULL. ● Domain Integrity Constraint. specifies that an attribute’s value must respect its domain. ● Referential Integrity Constraint. enforces the foreign key mechanism ● Other Constraints. other constraints can be specified in the database using mechanisms such as triggers or assertions.
When designing a database, we first draft a conceptual model with the ER model before designing the physical relational model with the logical relational model.
This process echoes the levels of abstraction in the previous topic.
With the given ER diagram, will now see how to transform our ER model into a relational model with the following steps.
● For one-to-many or many-to-one relationships between two strong entities: ○ Take the primary key from the entity representing the "one" side. ○ Add it as a foreign key to the entity representing the "many" side.
PROFESSOR(EmpNumber, FirstName, MiddleName, LastName, RankNumber) RANK(RankNumber, RankTitle)
PROFESSOR and RANK have a many-to-one cardinality. With that, we add the primary key of RANK as a foreign key in PROFESSOR.
● When two entities have a many-to-many relationship:
ENROLLS(StudentNumber, SubjectId) TEACHES(EmpNumber, SubjectId)
PROFESSOR and SUBJECT as well as STUDENT and SUBJECT have a many-to-many cardinality. With that, we create a new relation for each relationship and include the primary keys as foreign keys in the new relation.
Final Relational Schema ● PROFESSOR(EmpNumber, FirstName, MiddleName, LastName, RankNumber) ● RANK(RankNumber, RankTitle) ● STUDENT(StudentNumber, FirstName, MiddleName, LastName, Age) ● SUBJECT(SubjectId, SubjectTitle) ● SUBJECT_PREREQUISITE(SubjectId, Prerequisite) ● ENROLLS(StudentNumber, SubjectId) ● TEACHES(EmpNumber, SubjectId)
Logical Relational Model The resulting Logical Relational Model based on the Final Relational Schema is given below. The foreign keys are pointing to the primary keys from their original table (e.g. RankNumber in the PROFESSOR table is a foreign key that points to the RankNumber primary key in the RANK table). Each primary key is underlined.
Physical Relational Model The resulting Physical Relational Model based on the Logical Relational Model is given below.