0% found this document useful (0 votes)
7 views3 pages

ERD Exercises for Database Modeling

The document outlines a tutorial exercise set for second-year foundation training, focusing on creating Entity-Relationship Diagrams (ERDs) based on various scenarios including employee management, university admissions, project suppliers, and course enrollment systems. It includes specific tasks such as drawing ERDs, discussing relationships, defining keys, and revising diagrams to meet new requirements. The exercises aim to enhance understanding of database modeling and design principles.

Uploaded by

bekkasyahyaaegis
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

ERD Exercises for Database Modeling

The document outlines a tutorial exercise set for second-year foundation training, focusing on creating Entity-Relationship Diagrams (ERDs) based on various scenarios including employee management, university admissions, project suppliers, and course enrollment systems. It includes specific tasks such as drawing ERDs, discussing relationships, defining keys, and revising diagrams to meet new requirements. The exercises aim to enhance understanding of database modeling and design principles.

Uploaded by

bekkasyahyaaegis
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Department of Foundation Training- Second year

Tutorial – Exercise Set II (Modeling)

1. Draw an ERD for each of the following descriptions:


(a) The company stores each employee’s name (first, last, MI), Social Security number (SSN), street
address, salary, sex (gender), and birth date. An employee is assigned to one department, but may
work on several projects, which are not necessarily controlled by the same department. Keep track
of the current number of hours per week that an employee works on each project and the direct
supervisor of each employee.
(b) Extend the ERD of Question 1 to keep track of the direct supervisor of each employee (Note: the
supervisor is also an another employee of the company).
(c) The company wants to keep track of the dependents of each employee for insurance purposes. The
company keeps each dependent’s first name, sex, birth date, and relationship to the employee.
Extend the previous ERD
2. Consider that a university wants to keep track of undergraduate student’s admission. Given the following
rules:
– A student is admitted to one branch of engineering.
– A branch can have many students admitted in it.
– A branch is offered by one department.
– A department can offer many branches.
– The attributes of entity student include roll number, student name, and date of birth, gender and
year of admission.
– The attributes of entity branch include branch code and branch name.
– the attributes of entity department include department number and department name.
(a) Draw the corresponding ERD including relationship cardinalities
(b) The designer hired by the university added a relationship ”belongs to” between student and depart-
ment. Discuss this choice.
3. Given the two situations of the figure below :
(a) Design an E-R diagram for each of the two situations given that:
– Suppliers can supply products for projects. A supplier can supply a particular product for
multiple projects. A product for a particular project can be supplied by multiple suppliers.
– A project can have a particular supplier supply multiple products. Note that, the quantity
and due date, for supplying a product should also be recorded and: A supplier can supply a
particular product for 0 to N projects.
– A product for a particular project can be supplied by 0 to N suppliers.
– A supplier can supply 0 to N products for a particular project.
(b) Is the semantics of the first relationship type preserved by the second one? Discuss.
4. Given the following ERD :
(a) Define the primary and partial keys for each entity of the given ERD of figure 2
(b) Extend the ERD dpicted in figure 2 to include the following business rules

Introduction to Databases- [Link] 2025/2026 1 Oct 5, 2025


Department of Foundation Training- Second year

Figure 1: Design of two given situations

Figure 2: Undegraduate student’s admission ERD

– An instructor belongs to a one and only one department


– Students and instructors have several emails
– The database must record the location and the faculty of each department
– A department is identified by the DepNum and has a unique department name
– Each department has one Head of Department, an instructor may be a head for only one
department
– The department offers multiple courses and each course belongs to only one department
– Students can tutor other student(s)
– Each student is allocated an individual room in the university campus, rooms may be inallo-
cated.
(c) Following the ERD of figure 2, is it possible to have a class meeting at different places at different
times? Could the database have two classes meeting at the same place and time? Dicuss, if so
extend the ERD to fix this problem
(d) Extend the ERD so that the database records the marks that students get in different exams of
different course offerings
– Use two binary relationships

Introduction to Databases- [Link] 2025/2026 2 Oct 5, 2025


Department of Foundation Training- Second year

– Use a ternary relationship


5. A software company was asked to develop a course enrollment system. The client set the following
business rules:
– Courses are offered by faculties.
– A faculty can offer more than one course.
– The same course may be offered by more than one faculty.
– Students have the choice of enrolling a course with a faculty of his/her choice.
(a) Design an appropriate ERD.
(b) The previous ERD does not capture some other information such as:
– which offering (e.g., April 2024 November 2024) the student has enrolled for the course.
– whether the student has successfully completed the course or not. Note that, a student has
successfully completed a course if the grade obtained by this later is (‘A’, ‘B’, ‘C’, ‘D’, ‘E’).
He is unsuccessful if he has obtained a U grade.
Question: revise the ERD to take into consideration the new requirements.
(c) The previous ERD dos not tell us anything about the future enrollment, if a student is unsuccessful
in a course. Consider the following requirements:
– If the student is unsuccessful in a course, he must register for the course during the next session.
– The student need not redo the course by attending classes but must register for the course
during the next session.
Question: revise the ERD to take into consideration the new requirements.
(d) Revise the ERD to fulfill the following new requirement:
– If a student is unsuccessful in a course, he must redo the course by enrolling for the course offered
by a faculty (the same or a different faculty) and attend classes
6. Given the entities defined in the figure below:

Figure 3: A library sells management system

(a) Design an ERD (add eventual entities and relationships) to track sales of books to customers, based
on the following assumptions:
(A1): A customer may belong to many clubs
(A2): A club has many members
(A3): There can be several ”offers” available for a book which determines its price depending on
the club.
(b) Does your proposed ERD ensure that the Offer under which a customer buys a book is in accordance
with its membership? if not so, modify the ERD to fix this issue.
(c) Modify the proposed ERD, if it does not take into consideration the following constraint:
(A4): A customer can buy a given book via a given offer only once.
(d) Is it possible to modify the ERD in order to guarentee that a customer always pays the lowest price
for which he is eligible? Why?
7. Map the ERDs, of all the exercises, to their respective corresponding relational schemas.

Introduction to Databases- [Link] 2025/2026 3 Oct 5, 2025

Common questions

Powered by AI

Extending an ERD to track direct supervisors for employees becomes challenging when supervisors are also employees, due to recursive relationships. A self-referencing table approach can be used, where an 'Employee' entity has a 'supervisorID' that points to another 'Employee' entity. This introduces complexity in managing recursive data and ensuring queries correctly handle the hierarchy. One solution is to implement a hierarchical data model using parent-child relationships or incorporate database-specific features like Common Table Expressions (CTEs) to handle recursive queries. Moreover, creating views or abstracting recursive relationships using additional entities might simplify management and enhance clarity .

Mapping ERDs to relational schemas translates the conceptual design of a database into a logical structure. This mapping ensures that all entities and relationships are converted into tables (relations), complete with primary and foreign keys that maintain entity integrity and establish referential integrity. The schema adopts all constraints envisioned in the ERD, including cardinality constraints as series of relational rules that govern the types of operations that can occur on the data. This involves defining primary keys, which uniquely identify records, and foreign keys, which enforce relationships between tables, ensuring that all data adheres to defined relationships and constraints .

When converting an ERD into a relational schema, primary considerations include establishing primary keys for each entity to uniquely identify records and defining foreign keys to implement relationships. Relationships in the ERD should be analyzed to determine if they should be implemented as foreign keys or through additional relations in the schema. Maintaining referential integrity is crucial, ensuring that all foreign keys reference existing primary key values. Cardinality constraints in the ERD need to be reflected in the relational schema to uphold relationship rules, such as one-to-many or many-to-many associations potentially requiring associative tables. The schema should also accommodate necessary attributes and incorporate constraints that reflect the logical structure of the original ERD .

Using binary relationships for recording student marks for exams involves separate relationships between students and exams, and exams and course offerings. The advantage is simplicity in design and easier implementation, as binary relationships are generally more straightforward and less computationally expensive. They provide clearer relations and easier query formulation. However, the disadvantage is that binary relationships may not fully capture complex interdependencies between students, exams, and courses, leading potentially to data redundancy and complexity in maintaining consistent and accurate records when multiple connections are present. Ternary relationships, although more complex, accommodate a fuller representation of the involved interactions .

Adding a 'belongs to' relationship between a student and a department may be redundant if the existing structure already allows for this connection through indirect associations. In the university ERD, a student belongs to a branch, and every branch is part of a department. Therefore, the student's affiliation with a department can be inferred via their corresponding branch, making the direct 'belongs to' relationship unnecessary. Introducing another path could complicate the model, creating potential for redundancy and increased risk for anomalies in the data structure .

Ensuring that a customer always pays the lowest price for which they are eligible involves tracking all available offers and cross-referencing them against the customer's memberships and discounts. This challenge can be addressed through a well-designed ERD that includes entities for Customers, Offers, and Clubs. The ERD should ensure a strong association between customers and their eligible offers, possibly through associative entities that reflect pricing rules and discounts specific to club memberships. Furthermore, implementing additional business logic outside the ERD could automate price calculation by evaluating current offers and flagging the lowest price option. Such a comprehensive approach ensures data is aligned with business rules without compromising integrity .

To accommodate the requirement that unsuccessful students must register for the course in the next session without attending classes, the ERD would need to include an 'Enrollment' entity. This entity could have attributes indicating enrollment status and session details. A relationship between Students and Enrollment should indicate mandatory registration for the next session, regardless of class attendance. Additionally, a boolean attribute or status flag might be required in the Enrollment entity to identify whether a student needs to physically attend classes or just be listed as registered. Such modifications ensure that all sessions and attendance status are tracked efficiently .

Cardinality in ERD design specifies the number of instances of one entity that can be associated with the instances of another entity. In the university admissions ERD, a student is associated with one branch (1:1 cardinality between student and branch), and a branch can have many students (1:N cardinality between branch and student). Each branch is affiliated with one department (1:1 cardinality between branch and department), and a department can offer multiple branches (1:N cardinality between department and branch). These cardinality constraints ensure the integrity and restrict the data relationships, preserving the rules of uniqueness for attributes like branch code and department number. Cardinality helps in understanding limitations and capacities of associations in the database schema .

A ternary relationship in ERD design implies that three entities are involved simultaneously in a relationship. In the context of student exam marks across different course offerings, using a ternary relationship means that the relationship would involve students, exams, and courses as three interconnected entities. This model would capture the complex connection where a student can receive different marks for different exams in various offerings of the same course. It ensures that the interactions among these three entities are accurately represented in terms of data integrity and relationship constraints. Ternary relationships are complex as they need careful consideration of how attributes are shared and constraints enforced among all three entities .

If the initial ERD does not accommodate multiple courses being offered by various faculties, a revision would involve creating a many-to-many relationship between Course and Faculty through an associative entity like 'CourseOffering'. This entity should store data about which faculty offers the course, as well as offer details like semester or year. Additionally, another many-to-many relationship is needed between Students and CourseOfferings, allowing students to select courses based on their preferred faculty. This comprehensive structure ensures flexibility in course selection and tracks all faculty-offered course variations accurately .

You might also like