Skip to content

Entity-relationship Diagram Exercises And Answers Pdf Apr 2026

\sectionExercise 6: Supertype/Subtype (Generalization) \textbfScenario: \\ A vehicle rental system tracks vehicles. A vehicle can be either a Car or a Truck. \beginitemize \item All vehicles have: VIN (PK), make, model, year. \item Cars have: number of doors, fuel type. \item Trucks have: cargo capacity (tons), number of axles. \enditemize

% Better to use explicit relationship diamond for clarity \endtikzpicture \endfigure \noindent Alternative clear diagram: \beginfigure[H] \centering \begintikzpicture \node[rectangle, draw] (dept) DEPARTMENT; \node[rectangle, draw, below=2cm of dept] (emp) EMPLOYEE; \node[diamond, draw, left=1cm of dept] (works) WORKS\_IN; \node[diamond, draw, right=1cm of dept] (manages) MANAGES;

\sectionExercise 4: Hospital Management (Ternary Relationship) \textbfScenario: \\ A hospital records which doctor treats which patient on which date. \beginitemize \item \textbfDoctor: doctor\_id (PK), name, specialty. \item \textbfPatient: patient\_id (PK), name, illness. \item \textbfTreatment Date: date. \item A doctor may treat many patients on a given date; a patient may be treated by many doctors; and each treatment happens on a specific date. The combination (doctor, patient, date) is unique. \enditemize

\begindocument

\sectionIntroduction This document contains a collection of Entity-Relationship Diagram (ERD) exercises designed to help you practice database modeling. Each exercise presents a real-world scenario. Try to draw the ERD on your own first, then check the provided solution.

\section*Appendix: Quick ERD Notation Reference \begintcolorbox \begintabularl \hline \textbfSymbol & \textbfMeaning \\ \hline Rectangle & Entity \\ Oval & Attribute (sometimes omitted, listed inside entity) \\ Diamond & Relationship \\ Underline & Primary Key \\ Double Rectangle & Weak Entity \\ Double Diamond & Identifying Relationship \\ 1 at line end & One cardinality \\ M or * at line end & Many cardinality \\ Circle (O) & Optional participation \\ \hline \endtabular \endtcolorbox

\newpage

\draw (member) -- (borrows) node[midway, left] M; \draw (book) -- (borrows) node[midway, right] M; \endtikzpicture \captionLibrary ERD \endfigure \noindent Cardinality: Many-to-Many between MEMBER and BOOK via BORROWS.

\sectionExercise 2: Library System \textbfScenario: \\ A library wants to track books and members. \beginitemize \item \textbfBook: ISBN (unique), title, author, year. \item \textbfMember: member\_id (unique), name, phone. \item A member can borrow many books, but a specific copy of a book can be borrowed by only one member at a time (simplified: assume one copy per ISBN). \item A book may be borrowed by many members over time. \item The relationship \textbfBorrows has attributes: borrow\_date, return\_date. \enditemize

\newpage

\textbfTask: Draw a ternary relationship ERD.

\textbfNotation: We use \textbfCrow's Foot notation. \beginitemize \item Entities: Rectangles \item Primary Key: Underlined attribute \item Relationships: Diamonds (or labeled lines) with crow's foot for many side. \item Cardinalities: 1 (one), M (many), (0,1) optional one, etc. \enditemize

\titleEntity-Relationship Diagram (ERD) Exercises \\ with Answers \authorDatabase Design Workbook \date\today entity-relationship diagram exercises and answers pdf

\textbfTask: Draw the ERD. Identify primary keys, entity attributes, and relationship cardinality.

\vspace2cm \noindent\rule\textwidth0.5pt \textbfAnswer: \beginfigure[H] \centering \begintikzpicture[node distance=2.5cm, auto] % Student Entity \node[rectangle, draw, minimum width=2.5cm, minimum height=1cm] (student) STUDENT; \node[above=0.2cm of student] \textbfStudent; \node[below=0.1cm of student, align=center] \tiny student\_ID (PK)\\ name\\ major;