Entity-relationship Diagram Exercises And Answers Pdf Link
\begindocument
% Works-in (1 to many) \draw (dept) -- node[right] 1 ++(2,0) -- node[above] works-in ++(0,-1.5) -- node[left] M (emp); % Manages (1 to 1, but optional on employee side because not every employee is a manager) \draw[->, thick] (emp.east) -- ++(1.5,0) -- ++(0,1.5) -- node[above, midway] manages (1) (dept.east); \node at (3.5,-0.2) 1 (optional);
\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
\vspace2cm \noindent\rule\textwidth0.5pt \textbfAnswer: \beginfigure[H] \centering \begintikzpicture[node distance=2cm] \node[rectangle, draw] (doctor) DOCTOR; \node[rectangle, draw, below left=2cm and -0.5cm of doctor] (patient) PATIENT; \node[rectangle, draw, below right=2cm and -0.5cm of doctor] (date) DATE; \node[diamond, draw, aspect=2, below=1.5cm of doctor] (treats) TREATS; \draw (doctor) -- (treats); \draw (patient) -- (treats); \draw (date) -- (treats); \node at ($(doctor)!0.5!(treats)$) [left] M; \node at ($(patient)!0.5!(treats)$) [left] M; \node at ($(date)!0.5!(treats)$) [right] M; \endtikzpicture \captionTernary Relationship: TREATS \endfigure \noindent The relationship has cardinality M:M:M. In tables, the composite key is (doctor\_id, patient\_id, date). entity-relationship diagram exercises and answers pdf
\textbfTask: Draw an ERD with generalization (disjoint, total).
\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 the ERD showing a weak entity (Line Item) and its identifying relationship. \begindocument % Works-in (1 to many) \draw (dept)
\textbfTask: Draw a ternary relationship ERD.
\newpage
\textbfTask: Draw the ERD including entities, attributes, primary keys, and the many-to-many relationship with its attribute. \enditemize \vspace2cm \noindent\rule\textwidth0
\vspace2cm \noindent\rule\textwidth0.5pt \textbfAnswer: \beginfigure[H] \centering \begintikzpicture[node distance=2.5cm] \node[rectangle, draw] (member) MEMBER \\ \tiny member\_ID (PK) \\ name \\ phone; \node[rectangle, draw, right=3cm of member] (book) BOOK \\ \tiny ISBN (PK) \\ title \\ author \\ year; \node[diamond, draw, aspect=2, below=1.5cm of $(member.south)!0.5!(book.south)$] (borrows) BORROWS; \node[below=0.2cm of borrows] \tiny borrow\_date, return\_date;
\maketitle
\draw (dept) -- (manages) node[midway, above] 1; \draw (emp) -- (manages) node[midway, below] 1; \endtikzpicture \captionCompany ERD \endfigure