ER Design Project: College Database
A complete college database designed from a written requirement: entities, attributes, relationships, cardinality, participation, the ER diagram and the final relational schema with all keys.
-
DBMS Fundamentals
- Data, Information and Databases
- What a DBMS Is and Why It Exists
- File System versus DBMS
- Advantages and Limitations of a DBMS
- Database Users and the Role of the DBA
- Three Level Architecture and Data Abstraction
- Logical and Physical Data Independence
- Schema, Instance and Metadata
- Database Applications and the Database System Environment
- Database Architecture
- Data Models
-
ER Model
- Entities, Entity Sets and Entity Types
- Types of Attributes in the ER Model
- Keys in the ER Model
- Relationships, Relationship Sets and Degree
- Cardinality and Participation Constraints
- Strong and Weak Entities
- Drawing and Reading ER Diagrams
- Extended ER: Generalisation, Specialisation and Aggregation
- Converting an ER Diagram into Relational Tables
- ER Design Projects
- Relational Model
- Relational Algebra
- Functional Dependencies
-
Normalisation
- Why Normalisation Exists: Anomalies and Redundancy
- First Normal Form
- Second Normal Form and Partial Dependency
- Third Normal Form and Transitive Dependency
- BCNF and BCNF Decomposition
- 4NF, 5NF, Multivalued and Join Dependencies
- Lossless Decomposition and Dependency Preservation
- Complete Worked Normalisation: Unnormalised to BCNF
- Denormalisation and When to Use It
Requirement
A college is organised into departments. Each department has a code, a name, a building and exactly one head of department, who must be one of the faculty members. A department may exist before any student joins it.
Every student belongs to exactly one department and has a roll number, a name, a date of birth, one email address and possibly several phone numbers. The office also needs the student age, but it must always be correct.
Faculty members have a staff number, a name and a designation, and each belongs to exactly one department. A faculty member may teach several courses and a course may be taught by several faculty members in different semesters.
Courses have a code, a title and credits, and each is offered by exactly one department. A course may require other courses as prerequisites.
Students enrol in courses. For each enrolment the college records the semester, the attendance percentage and the marks. A student may repeat a course in a later semester.
Step 1 — Entities and attributes
| Entity | Attributes | Key |
|---|---|---|
| DEPARTMENT | dept_code, dept_name, building | dept_code |
| STUDENT | roll_no, name (composite), dob, age (derived), email, phone (multivalued) | roll_no |
| FACULTY | staff_no, name, designation | staff_no |
| COURSE | course_code, title, credits | course_code |
Two attributes need care. age is derived, because the requirement says it must always be correct — so it is computed from dob and never stored. phone is multivalued, so it will become its own table.
Step 2 — Relationships, cardinality and participation
| Relationship | Between | Ratio | Participation | Attributes |
|---|---|---|---|---|
| BELONGS_TO | STUDENT — DEPARTMENT | N:1 | Student total, department partial | — |
| WORKS_IN | FACULTY — DEPARTMENT | N:1 | Faculty total, department partial | — |
| HEADS | FACULTY — DEPARTMENT | 1:1 | Department total, faculty partial | — |
| OFFERS | DEPARTMENT — COURSE | 1:N | Course total, department partial | — |
| TEACHES | FACULTY — COURSE | M:N | Both partial | semester, section |
| ENROLS | STUDENT — COURSE | M:N | Both partial | semester, attendance, marks |
| PREREQUISITE | COURSE — COURSE | M:N recursive | Both partial | — |
Step 3 — The ER diagram
(dept_code) (dept_name) (building) (staff_no) (designation)
| / | /
+-----------------+ N 1 +---------+
| DEPARTMENT |----< WORKS_IN >----| FACULTY |
+--------+--------+ +----+----+
1 | | 1 | M
| +====< HEADS >=========1========+
| (department TOTAL) |
< OFFERS > < TEACHES >--( semester )
| N | N \_( section )
+-----v-----+ |
| COURSE |<------------------------------+
+-----+-----+
| | (course_code)(title)(credits)
| +----< PREREQUISITE >----+
| roles: requires / |
| required_by ---+
| N
< ENROLS >--( semester )( attendance )( marks )
| M
+-----v------+
| STUDENT |==== BELONGS_TO ====> DEPARTMENT (student TOTAL)
+------------+
(roll_no)(dob)(email)((phone))(name{first,last})(age dashed)Step 4 — The relational schema
departments ( dept_code PK
, dept_name NOT NULL
, building
, head_staff_no NOT NULL UNIQUE -> faculty )
faculty ( staff_no PK
, faculty_name NOT NULL
, designation
, dept_code NOT NULL -> departments )
students ( roll_no PK
, first_name NOT NULL
, last_name
, dob NOT NULL
, email UNIQUE
, dept_code NOT NULL -> departments )
-- age is NOT a column; it is computed
student_phones ( roll_no -> students ON DELETE CASCADE
, phone
, PK ( roll_no, phone ) )
courses ( course_code PK
, title NOT NULL
, credits NOT NULL
, dept_code NOT NULL -> departments )
teaches ( staff_no -> faculty
, course_code -> courses
, semester
, section
, PK ( staff_no, course_code, semester, section ) )
enrolments ( roll_no -> students
, course_code -> courses
, semester
, attendance
, marks
, PK ( roll_no, course_code, semester ) )
prerequisites ( course_code -> courses
, requires_code -> courses
, PK ( course_code, requires_code ) )
8 tables.
Created by: 4 entities, 1 multivalued attribute,
3 many to many relationships.
The three 1:N and 1:1 relationships created NO tables.Step 5 — Why each decision was made
| Decision | Reason |
|---|---|
head_staff_no on departments, not faculty | The 1:1 is total on the department side. Placing it on faculty would leave it null for nearly every row. |
semester inside the enrolment key | The requirement allows repeating a course, so roll_no and course_code alone are not unique. |
Separate student_phones table | Phone is multivalued. Columns phone1, phone2 would break on the third number. |
No age column | Derived. Storing it makes it wrong the next day. |
dept_code NOT NULL on students | Total participation: every student must belong to a department. |
prerequisites as its own table | A recursive many to many relationship always needs one. |
Verification questions
A design is only finished when it can answer the questions the requirement implies. Check each one can be answered from the schema above.
- Which students are in the Computing department?
- What are the phone numbers of one student?
- Which courses does one faculty member teach this semester?
- Which students failed a course, and did they repeat it later?
- What must a student have passed before enrolling in a given course?
- Who heads each department, and which department do they work in?
A deliberate trap
A faculty member heads a department and also works in one. Nothing above forces them to be the same department, and the requirement does not say they must be. If the college does require it, that is a rule the schema alone cannot express — it needs an explicit check or a trigger. Noticing that a requirement is silent, and saying so, is exactly what design review is for.
Common mistakes
- Storing
dept_nameon students instead of a foreign key, which repeats the name on every row. - Making enrolment key just roll_no and course_code, silently losing the repeat attempt.
- Modelling phone as three columns.
- Placing the head foreign key on faculty and leaving it null everywhere.
- Forgetting the prerequisite relationship is recursive and needs role names.
Practice
- Add a rule that each course runs in a fixed set of rooms at fixed times. Which entity and which relationships change?
- Add hostel allocation, where a student may hold at most one room and a room holds up to three students. Give the cardinality and the resulting table.
- Write the constraint needed to force a head of department to work in the department they head.
Conclusion
Eight tables, produced by applying the seven conversion rules to a design built from the eight step method. The valuable habits here are checking participation before writing NOT NULL, and testing the finished schema against the questions the requirement implies.