CSC 480 · Database Management
Our notes
2 min readBuilding blocks
- Entity: a thing of interest with independent existence (Student, Course, Department). An entity type is the set; an entity is one member.
- Attribute: a property (MatNo, Name, Level).
Kinds: simple vs composite (Name = first + surname); single-valued vs multi-valued (phone numbers); stored vs derived (Age from DateOfBirth, CGPA from results).
- Key attribute: uniquely identifies an entity (MatNo).
- Relationship: an association among entities (Student REGISTERS Course).
Chen notation
Rectangles = entity types; ellipses = attributes (key underlined; double ellipse = multi-valued; dashed = derived); diamonds = relationships; double rectangle = weak entity.
Crow's foot notation (used in most tools) shows cardinality with line ends.
Constraints on relationships
- Degree: unary (recursive: Student MENTORS Student), binary (most common), ternary (Lecturer TEACHES Course IN Semester).
- Cardinality ratio: 1:1 (Department HEADED BY Lecturer), 1:N (Department OFFERS Course), M:N (Student REGISTERS Course).
- Participation: total (every course must belong to a department: double line) or partial (not every lecturer heads a department).
- Relationships can have attributes: REGISTERS has Score and Session.
Weak entities
Cannot be identified by their own attributes alone; depend on an owner entity. Example: Dependant of an Employee (identified by EmployeeNo + DependantName); a Hostel Room identified by Hall + RoomNo.
Enhanced E-R (EER)
- Specialisation: a superclass divided into subclasses (Person → Student, Staff). Generalisation is the reverse (combine Lecturer and Technician into Staff).
- Constraints: disjoint vs overlapping (can a person be both student and staff? yes: postgraduate assistants, so overlapping), total vs partial.
- Subclasses inherit the superclass's attributes and relationships.
Mapping E-R to tables
- Each strong entity → a table; key → primary key; composite attributes → their simple parts.
- Weak entity → table with the owner's key plus its partial key as the primary key.
- 1:N relationship → put the "one" side's key as a foreign key in the "many" side's table (Course gets DeptCode).
- 1:1 → foreign key on the side with total participation.
- M:N → a new junction table with both keys (Registration(MatNo, CourseCode, Session, Score)).
- Multi-valued attribute → a separate table (StudentPhone(MatNo, Phone)).
- Specialisation → one table per class sharing the key, or one table with a type column.
Worked example (running database).
Department(DeptCode, DeptName, Faculty)
Student(MatNo, FirstName, Surname, Level, DeptCode → Department)
Course(CourseCode, Title, Units, DeptCode → Department)
Registration(MatNo → Student, CourseCode → Course, Session, Score)
Exams usually ask: draw an E-R diagram for a described scenario (library, hospital, hostel allocation, course registration); identify attribute types; cardinality and participation; weak entities; map an E-R diagram to relations.
Common mistake: putting a multi-valued or M:N fact into a single column (a "Courses" column holding a list). M:N relationships always become a separate table.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Entity–relationship model
(opens en.wikipedia.org in a new tab)
Wikipedia, Entity–relationship model, CC BY-SA 4.0 · licence
Watch
-
Best pick Basic Concepts of Entity-Relationship Model
9 min · ≈ 41 MB · about ₦23
(opens youtube.com in a new tab)
-
Entity-Relationship (ER) Diagram
17 min · ≈ 77 MB · about ₦43
(opens youtube.com in a new tab)
-
Entity Relationship Diagram (ERD) Tutorial - Part 1
6 min · ≈ 27 MB · about ₦15
(opens youtube.com in a new tab)
-
Entity Relationship Diagram (ERD) Tutorial - Part 2: Primary keys, foreign keys, and bridge tables
15 min · ≈ 68 MB · about ₦38
(opens youtube.com in a new tab)
-
Database Design Course - Learn how to design and plan a database for beginners
8 h 7 min · ≈ 2.1 GB · about ₦1,231
(opens youtube.com in a new tab)
-
Relational Database Design – Full Course
5 h 55 min · ≈ 1.6 GB · about ₦897
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.