XII Festival de Cine de Calzada de Calatrava 1 /11 Octubre 2025

Entity-relationship Diagram Exercises And Answers Pdf File

\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

% 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;

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

\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 entity-relationship diagram exercises and answers pdf

\newpage

\draw (dept) -- (works) node[midway, above] 1; \draw (emp) -- (works) node[midway, below] M;

% 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); \vspace2cm \noindent\rule\textwidth0

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

\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 \item \textbfTreatment Date: date

\newpage

\vspace2cm \noindent\rule\textwidth0.5pt \textbfAnswer: \beginfigure[H] \centering \begintikzpicture[node distance=2cm, auto] \node[rectangle, draw] (dept) DEPARTMENT \\ \tiny dept\_no (PK) \\ name \\ budget; \node[rectangle, draw, below=2cm of dept] (emp) EMPLOYEE \\ \tiny emp\_ID (PK) \\ name \\ salary;