UPI Study › Courses › System Analysis and Design › Free lessons › Lesson 6.4 Free with a free account
The Entity-Relationship Model: Diagrams Made Simple
System Analysis and Design · Chapter 6: Database Design, Normalization, and Business IntelligenceSection 6.4 · lesson 42 of 698 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of System Analysis and Design.
Lesson complete
Earn the 3 college credits for System Analysis and Design
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Normalization in Databases: Types and Practical Illustrations →← Approaches to Designing Database SchemasNext lesson: Normalization in Databases: Types and Practical Illustrations →
In this lesson
Entities, attributes, relationships, two notations, and mapping to tables.
- Define an entity and the types of attribute it can have
- Explain relationships, cardinality, and participation
- Explain weak entities, and compare Chen and Crow's Foot notation
- Map an entity-relationship diagram to a set of tables
Transcript
Everything said in the video, section by section (1,145 words). Read along, or search it.
Database Design, Normalization, and Business Intelligence
The Entity-Relationship Model
Before tables are designed, the data is modeled. And the standard tool for that is the entity-relationship diagram. This section covers entities and their attributes, relationships and how to describe them, and weak entities. Then two notations for drawing all of this, Chen and Crow's Foot. And finally, a worked example, and the rules for turning a diagram into real database tables.
Entities
Things the Database Tracks
An entity-relationship diagram, or E R D, models a database around entities. An entity is a distinct real-world thing the database needs to store data about, such as a customer, or a product. The idea of type and instance works just like class and object from earlier in the course. Customer is the entity type. And one particular customer is a specific instance of it.
Describing Entities
6 Types of Attribute
Each entity is described by attributes. And not all attributes work the same way. A simple attribute cannot be meaningfully divided into smaller parts. G P A, for example. A composite attribute can be broken into smaller, meaningful parts. An address has a street, city, state, and zip. A single-valued attribute holds exactly one value for each instance, like a date of birth. A multi-valued attribute can hold more than one value, like a set of phone numbers. A derived attribute is calculated from another attribute, rather than stored. Age can be derived from the date of birth. And a key attribute uniquely identifies each instance, like a student I D. These distinctions matter later, when the diagram becomes tables. A multi-valued attribute, for instance, cannot simply become one column.
Relationships
How Entities Associate
A relationship describes how two entities are associated. It is usually named with a verb phrase. A customer places an order. An instructor teaches a course. A relationship can even connect an entity to itself, as when one employee manages another employee. Cardinality describes how many instances of one entity can relate to instances of the other. In one-to-one, one instance of A relates to at most one of B. One employee has one employee badge. In one-to-many, one instance of A relates to many of B. One customer places many orders. And in many-to-many, many of A relate to many of B. Many students enroll in many courses.
Participation
Required or Optional?
Participation adds one more detail. Is an entity's involvement required? Mandatory, or total, participation means every instance must participate. An order must have a customer. An order with no customer makes no sense. Optional, or partial, participation means an instance may or may not participate. A customer might not have placed any order yet, and that is perfectly valid. Cardinality tells you how many. Participation tells you whether at all. Together, they describe a relationship fully.
Weak Entities
Identity Borrowed From an Owner
Most entities can be identified using their own key alone. A weak entity cannot. It depends on a related owner entity for its identity, and only makes sense in the context of that owner. Take an order line. A line item has no identity of its own, separate from the order it belongs to. It is usually identified by its owning order, plus a partial key, such as a line number. Line three means nothing on its own. Line three of order one hundred means something. The relationship connecting a weak entity to its owner is called an identifying relationship.
2 Notations
Chen vs. Crow's Foot
The same concepts can be drawn in different notations. Two are especially common. In both, an entity is drawn as a rectangle. The difference is in how relationships appear. Chen notation gives the relationship its own shape, a diamond, labeled with the verb phrase, such as places. Cardinality is written as a label beside the line. One on the customer side, and M, for many, on the order side. Crow's Foot notation has no separate shape. The line itself carries the relationship name. Cardinality is drawn right onto the ends of the line. A single tick across the line means one. A three-pronged fork, the crow's foot, means many. Both notations can say exactly the same thing. One customer places many orders. Crow's Foot has become more common in modern modeling tools. But Chen notation is still widely taught, because its diamond makes the relationship itself easy to see.
Figure 6.2
Worked ERD: Order Processing
Here is a worked E R D, in Crow's Foot notation, for a small order-processing database. Read each line by its ends. Between customer and order, there is a tick at customer, and a fork at order. So one customer places many orders. Each order consists of many order lines. And each product can appear in many order lines. Order line has a double border, marking it as a weak entity. A line item means nothing apart from its order. Now notice something clever. Order and product have a many-to-many relationship. An order holds many products, and a product appears on many orders. An E R D cannot represent many-to-many directly, so the relationship is routed through order line. Order line is exactly the entity that resolves it.
From Diagram to Database
Mapping an ERD to Tables
Once an E R D is complete, it can be translated into actual tables with a few consistent rules. Each entity becomes a table. Customer, order, order line, and product each become their own table. Each attribute becomes a column. An order's date and status become columns in the order table. The key attribute becomes the primary key. Customer I D becomes the primary key of the customer table. A one-to-many relationship posts the one side's key onto the many side, as a foreign key. So customer I D is added as a foreign key column in the order table. A many-to-many relationship becomes its own junction table. Order line resolves order and product, by holding both an order I D and a product I D. And a weak entity's primary key includes its owner's key. Order line's primary key is the combination of order I D, inherited from order, and a line number.
Key Terms
The Vocabulary of This Section
Let's lock in the key terms. An entity is a real-world thing the database tracks. An attribute is a property describing it. Cardinality is how many instances relate. One-to-one, one-to-many, or many-to-many. Participation is whether involvement in a relationship is mandatory or optional. A weak entity is identified only through an owner, via an identifying relationship. Chen notation uses a labeled diamond, with one and M. Crow's Foot uses a tick and a fork on the line. And a junction table is the table that resolves a many-to-many relationship.
Key Takeaways
What to Carry Forward
To pull this together. An entity's attributes can be simple, composite, single-valued, multi-valued, derived, or a key. A relationship is described by its cardinality, and by participation, mandatory or optional. A weak entity depends on an owner entity, connected through an identifying relationship. Chen notation uses a labeled diamond for each relationship. Crow's Foot draws cardinality directly on the line. And when mapping to tables, entities become tables, keys become primary keys, one-to-many relationships use foreign keys, and many-to-many relationships use junction tables.
About System Analysis and Design at UPI Study
System Analysis and Design (Computer Science 390) is a self-paced online course of 69 video lessons in 9 chapters, from the analyst's role and requirements to UML modeling, interface and database design, testing, maintenance and project management. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Why take it here
Why students take System Analysis and Design with UPI Study
Where the credit goes
Universities that work with NCCRS
System Analysis and Design carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About The Entity-Relationship Model: Diagrams Made Simple
What are the different types of attributes in an ER diagram?
What is the difference between cardinality and participation in an ER diagram?
What is a weak entity in an entity-relationship diagram?
How do you convert an ER diagram into database tables?
About the System Analysis and Design course
How many college credits is System Analysis and Design?
How much does System Analysis and Design cost and what is included?
Which universities accept UPI Study credits?
How long does System Analysis and Design take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in System Analysis and Design.
69 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
3 credits · NCCRSEnroll →