Entity-relationship Diagram Exercises And Answers Pdf Site

% Course Entity \node[rectangle, draw, minimum width=2.5cm, minimum height=1cm, right=of student] (course) COURSE; \node[above=0.2cm of course] \textbfCourse; \node[below=0.1cm of course, align=center] \tiny course\_code (PK)\\ title\\ credits;

\sectionExercise 5: Weak Entity Example (Order-Item) \textbfScenario: \\ An e-commerce system has orders and line items. \beginitemize \item \textbfOrder: order\_number (PK), order\_date, customer\_name. \item \textbfLine Item: item\_number (only unique per order), product\_name, quantity, price. \item A line item cannot exist without an order. The combination (order\_number, item\_number) uniquely identifies a line item. \enditemize

\textbfTask: Draw an ERD with generalization (disjoint, total).

\newpage

\vspace2cm \noindent\rule\textwidth0.5pt \textbfAnswer: \beginfigure[H] \centering \begintikzpicture \node[rectangle, draw] (order) ORDER \\ \tiny order\_number (PK) \\ order\_date \\ customer\_name; \node[rectangle, draw, double, below=1.5cm of order] (item) LINE ITEM \\ \tiny (weak entity); \node[diamond, draw, aspect=2, left=0.5cm of $(order.south)!0.5!(item.north)$] (contains) CONTAINS; \draw (order) -- (contains); \draw (contains) -- (item); \node[below=0.2cm of item, align=center] \tiny partial key: item\_number \\ attributes: product\_name, quantity, price; \endtikzpicture \captionWeak Entity LINE ITEM identified by ORDER \endfigure

\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

% Optional: show as associative entity? For clarity, many-to-many with attribute. \endtikzpicture \captionERD for University Enrollment (Many-to-Many with attribute) \endfigure \noindent\textitNote: In physical design, ENROLLS becomes a bridge table containing student\_ID, course\_code, and enrollment\_date. entity-relationship diagram exercises and answers pdf

\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.

\tableofcontents \newpage

\sectionExercise 1: University Database \textbfScenario: \\ A university needs a database to manage its courses and students. \beginitemize \item Each \textbfStudent has a unique student ID, name, and major. \item Each \textbfCourse has a unique course code, title, and credits. \item A student can enroll in many courses. A course can have many students. \item The enrollment date should be recorded as an attribute of the relationship. \enditemize % Course Entity \node[rectangle, draw, minimum width=2

% Lines \draw (student) -- (enroll) node[midway, left] M; \draw (course) -- (enroll) node[midway, right] M;

\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.

\titleEntity-Relationship Diagram (ERD) Exercises \\ with Answers \authorDatabase Design Workbook \date\today \item A line item cannot exist without an order

\newpage