ER/EER Diagrams for Company and Sports Team

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In an ER diagram for a company database, if an employee can manage only one department, and a department is managed by one employee, what type of relationship exists between 'Employee' and 'Department'?

  • One-to-many
  • One-to-one (correct)
  • Many-to-one
  • Many-to-many

Which constraint ensures that a column in a table does not accept NULL values?

  • Primary Key
  • Unique
  • Foreign Key
  • Not Null (correct)

Which type of attribute cannot be directly stored in a database and is derived from other attributes?

  • Key attribute
  • Derived attribute (correct)
  • Multivalued attribute
  • Composite attribute

In a relational database, what is the purpose of a foreign key?

<p>To establish and enforce a link between data in two tables. (B)</p> Signup and view all the answers

If an entity set does not have sufficient attributes to form a primary key, how is it termed?

<p>Weak entity set (D)</p> Signup and view all the answers

What does the cardinality ratio specify in the context of relationships between entities?

<p>The number of instances of an entity in a relation that can be associated with another relation. (C)</p> Signup and view all the answers

Which SQL constraint is used to enforce a specific rule on a column?

<p>CHECK (D)</p> Signup and view all the answers

In ER modeling, what does total participation of an entity in a relationship mean?

<p>Each entity instance must participate in the relationship. (A)</p> Signup and view all the answers

When mapping an M:N relationship between two entities E1 and E2 to a relational model, what is typically created?

<p>A new relation (table) containing the primary keys of E1 and E2. (B)</p> Signup and view all the answers

Which of the following is a recursive relationship?

<p>A relationship where an entity is related to itself. (A)</p> Signup and view all the answers

Which step in mapping an ER/EER model to a relational database schema involves creating a new relation that includes an attribute corresponding to the multi-valued attribute, plus the primary key as a foreign key?

<p>Mapping of Multi-valued attributes (D)</p> Signup and view all the answers

Which of the following is NOT a valid rule for defining a primary key?

<p>The value in a primary key column can be modified or updated even if a foreign key refers to it. (D)</p> Signup and view all the answers

If a directed line (-->) exists from the relationship set 'advisor' to both entity sets 'instructor' and 'student', what cardinality does this indicate?

<p>One to many (A)</p> Signup and view all the answers

When converting a specialization/generalization with superclass C and subclasses {S1, S2,….,Sm} into relational schemas, which option involves creating multiple relations for superclass and subclasses?

<p>Multiple relations - Superclass and subclasses (A)</p> Signup and view all the answers

Given two relation schemas (A, B) and (C, D) where B is a foreign key that refers to C in the second relation, what must hold true if the data satisfies referential integrity constraints?

<p>Every value of B must exist as a value of C. (B)</p> Signup and view all the answers

Which of the following SQL commands is used to add a new column to an existing table?

<p>ALTER TABLE (A)</p> Signup and view all the answers

What does the term 'normalization' refer to in the context of database design?

<p>The process of organizing data to reduce redundancy and improve data integrity. (A)</p> Signup and view all the answers

Which type of relationship requires the creation of a new table to properly implement it in a relational database?

<p>Many-to-many (B)</p> Signup and view all the answers

Using the following CREATE TABLE statement, what constraint can be used to make sure that the budget can never be below 0?

<p>CHECK (budget &gt;= 0) (D)</p> Signup and view all the answers

S1: A foreign key declaration can always be replaced by an equivalent check assertion in SQL. S2: Given the table R(a,b,c) where a and b together form the primary key, the following is a valid table definition. CREATE TABLE S ( a INTEGER, d INTEGER, e INTEGER, PRIMARY KEY (d), FOREIGN KEY (a) references R). Which one of the following statements is CORRECT?

<p>S1 is FALSE and S2 is TRUE (C)</p> Signup and view all the answers

Consider an ER diagram with entities M, N, and P, and relationships R1 (M-N) and R2 (N-P). R1 is 1:N and R2 is M:N. What is the minimum number of tables needed to represent M, N, P, R1, and R2?

<p>3 (C)</p> Signup and view all the answers

Consider an ER diagram with entities M, N, and P, and relationships R1 (M-N) and R2 (N-P). R1 is 1:N and R2 is M:N. Which of the following is a correct attribute set for one of the tables for the correct answer to the above question?

<p>{M1, P1, N1} (A)</p> Signup and view all the answers

Let E1 and E2 be two entities in an E/R diagram with simple single-valued attributes. R1 and R2 are two relationships between E1 and E2, where R1 is one-to-many and R2 is many-to-many. R1 and R2 do not have any attributes of their own. What is the minimum number of tables required to represent this situation in the relational model?

<p>4 (A)</p> Signup and view all the answers

What is the min and max number of tables required to convert an ER diagram with 2 entities and 1 relationship between them with partial participation constraints of both entities?

<p>Min 2 and max 2 (C)</p> Signup and view all the answers

In which of the following scenarios is a separate schema created, consisting of that attribute and the primary key of the entity set?

<p>A multivalued attribute of an entity set (B)</p> Signup and view all the answers

Which of the following indicates the maximum number of entities that can be involved in a relationship?

<p>Maximum Cardinality (A)</p> Signup and view all the answers

Given the basic ER and relational models, which of the following is INCORRECT?

<p>In a row of a relational table, an attribute can have more than one value (C)</p> Signup and view all the answers

Suppose you want to keep track of different types of vehicles (cars, trucks, motorcycles) and their unique attributes in a database. Which EER modeling construct is most suitable for representing this?

<p>Generalization/Specialization (B)</p> Signup and view all the answers

What is the purpose of mapping EER model constructs to relations?

<p>To represent conceptual database design in a logical (relational) database design (B)</p> Signup and view all the answers

Which type of integrity constraint is specifically designed to maintain the accuracy and consistency of data by ensuring that relationships between tables remain valid?

<p>Referential integrity (A)</p> Signup and view all the answers

What is the main purpose of creating an ER diagram?

<p>To model the data requirements of an information system (B)</p> Signup and view all the answers

Which of the following is the correct SQL syntax to add a primary key constraint to an existing table named 'Employees' on the column 'EmployeeID'?

<p><code>ALTER TABLE Employees ADD CONSTRAINT PK_EmployeeID PRIMARY KEY (EmployeeID);</code> (A)</p> Signup and view all the answers

What is a 'surrogate key' primarily used for when mapping union types (categories) in a database?

<p>To serve as a primary key for a category whose superclasses have different keys (D)</p> Signup and view all the answers

If you have a 'Customers' table and an 'Orders' table, and each customer can place multiple orders, what type of relationship exists, and how would you typically implement it in a relational database?

<p>One-to-many, by adding a foreign key in the 'Orders' table referencing the 'Customers' table (D)</p> Signup and view all the answers

In SQL, which constraint ensures that all values in a column are different?

<p>UNIQUE (A)</p> Signup and view all the answers

State true or false: Every weak entity must be associated with an identifying entity.

<p>True (A)</p> Signup and view all the answers

Flashcards

Entity

A real-world object distinguishable from other objects, described using a set of attributes.

Entity Set

A collection of similar entities (e.g., all employees) with the same set of attributes and a key.

Attributes

Properties used to describe an entity, such as Name, SSN, Address, or BirthDate for an EMPLOYEE entity.

Relationship

Relates two or more distinct entities with a specific meaning; grouped into a relationship type (Unary, Binary, Ternary).

Signup and view all the flashcards

Recursive Relationship

A relationship where the same entity type participates in distinct roles.

Signup and view all the flashcards

Cardinality Ratio

Semantics of relationships indicating the number of instances of an entity that can be associated with the relation.

Signup and view all the flashcards

Participation Constraints

Constraints that specify whether an entity must participate in a relationship (Total) or may not participate (Partial).

Signup and view all the flashcards

Total Participation

Each entity is involved in the relationship.

Signup and view all the flashcards

Partial Participation

Not all entities are involved in the relationship.

Signup and view all the flashcards

Primary Key

A column or group of columns that uniquely identifies every row in a table and cannot contain duplicate values or nulls.

Signup and view all the flashcards

Foreign Key

A constraint that identifies a column referencing the PRIMARY KEY in another table, establishing a relationship between tables.

Signup and view all the flashcards

NOT NULL Constraint

Ensures all rows in the table contain a definite value for the column, disallowing null values.

Signup and view all the flashcards

Unique Key

Ensures that a column or group of columns in each row have a distinct value; a column(s) can have a null value but the values cannot be duplicated.

Signup and view all the flashcards

Check Constraint

Defines a business rule on a column that all rows must satisfy; can be applied for a single column or a group of columns.

Signup and view all the flashcards

Mapping Regular Entity Types

Create a relation R that includes all the simple attributes of E. Choose one of the key attributes of E as the primary key for R.

Signup and view all the flashcards

Mapping Weak Entity Types

Include as foreign key attributes of R the primary key attribute(s) of the relation(s) that correspond to the owner entity type(s).

Signup and view all the flashcards

Mapping Binary 1:1 Relation Types

Identify the relations S and T that correspond to the entity types participating in R. Foreign Key Approach, Merged Relation Option, Cross-reference.

Signup and view all the flashcards

Mapping Binary 1:N Relationship Types

Include as foreign key in S the primary key of the relation T that represents the other entity type participating in R.

Signup and view all the flashcards

Mapping Binary M:N Relationship Types

Include as foreign key attributes in S the primary keys of the relations that represent the participating entity types; their combination will form the primary key of S.

Signup and view all the flashcards

Mapping Multi-valued attributes

Relation R will include an attribute corresponding to A, plus the primary key attribute - as a foreign key in R - of the relation that represents the entity type.

Signup and view all the flashcards

Mapping of N-ary Relationship Types

Include as foreign key attributes in S the primary keys of the relations that represent the participating entity types.

Signup and view all the flashcards

Study Notes

  • These notes cover ER/EER diagrams for database design, relational schema mapping, and SQL integrity constraints, particularly within the context of designing databases for a company and a sports team.

Experiment 1: ER/EER Diagram Design

  • Objective is to design ER/EER diagrams for a COMPANY and a SPORTS TEAM database.
  • The program outcome is for students to be able to draw conceptual database designs using ERD Plus.

COMPANY Database

  • Stores information about employees, departments, and projects.
  • Departments control several projects which each have a unique name, number, and location.
  • Each department has a unique name and number, is managed by an employee, and can have multiple locations.
  • The database tracks the start date of the employee managing the department.
  • Employee data includes name, Social Security number, address, salary, sex, and birth date.
  • Employees are assigned to one department but can work on several projects.
  • The database keeps track of the hours per week an employee works on each project, as well as their direct supervisor.
  • Dependent information (first name, sex, birth date, relationship) is tracked for insurance purposes.

SPORTS TEAM Database

  • The goal is to keep track of matches played, scores, players in each match, and individual player statistics.
  • Summary statistics should be modeled as derived attributes.
  • The database should track the same information for all teams in a league.

Key Elements of ER/EER Model

  • Entities: Distinguishable real-world objects, can be strong or weak.
  • Relationships: Associations between two or more entities (Unary, Binary, Ternary, Recursive).
  • Participation Constraints: Total (entity involved in the relationship) or Partial (not all entities involved).
  • Attributes: Properties describing an entity, it has a domain.
  • Recursive Relations: Relationship where the same entity type participates in distinct roles.
  • Mapping Cardinalities: Number of instances of an entity in a relation.
  • Binary/Ternary Relationships: Relationships involving two or three entities.
  • Specialization/Generalization: Hierarchical relationships between entity types.

ER Diagram Symbols and Notations

  • Entity: A real-world object that is distinguishable from other objects.
  • Entity Set: A collection of similar entities with the same attributes and a key.
  • Attributes Properties used to describe an entity (e.g., Name, SSN, Address for an "EMPLOYEE" entity).
  • Relationship: Relates two or more distinct entities with a specific meaning.
  • Cardinality Ratio: The number of instances of an entity from a relation.

Preparatory Questions and Answers

  • An attribute of an entity can have more than one value.
  • A directed line from the relationship set advisor to both entity sets instructor and student indicates one to many cardinality.
  • An entity set without sufficient attributes to form a primary key is a Weak entity set.
  • Maximum Cardinality indicates the maximum number of entities involved in a relationship.
  • Every weak entity must be associated with an identifying entity is True.

Experiment 2: Relational Database Schema Design

  • Objective to design a Relational Database Schema for the COMPANY and SPORTS TEAM database from the ER/EER diagram.
  • The program outcome is for students to map the conceptual database design to logical (relational) database design.
  • Step 1: Mapping of Regular Entity Types
  • Step 2: Mapping of Weak Entity Types
  • Step 3: Mapping of Binary 1:1 Relation Types
  • Step 4: Mapping of Binary 1:N Relationship Types
  • Step 5: Mapping of Binary M:N Relationship Types
  • Step 6: Mapping of Multivalued attributes
  • Step 7: Mapping of N-ary Relationship Types
  • Step 8: Mapping EER Model Constructs to Relations
  • Step 9: Options for Mapping Specialization or Generalization
  • Step 10: Mapping of Union Types (Categories)

Steps for Mapping ER/EER Model to Relational Tables

  • Mapping Regular Entity Types: Create a relation for each strong entity type including all simple attributes; choose a primary key.
  • Mapping Weak Entity Types: Create a relation for each weak entity type; include all simple attributes and the primary key of the owner entity type as a foreign key.
  • Mapping Binary 1:1 Relationship Types: Can be implemented via: Foreign Key Approach, Merged Relation Option, or Cross-reference.
  • Mapping Binary 1:N Relationship Types: Include the primary key of the entity on the '1' side as a foreign key in the relation representing the entity on the 'N' side.
  • Mapping Binary M:N Relationship Types: Create a new relation to represent the relationship, including the primary keys of both participating entities as foreign keys; their combination forms the primary key of the new relation.
  • Mapping Multi-valued Attributes: Create a new relation including an attribute for the multi-valued attribute and the primary key of the original relation as a foreign key.
  • Mapping N-ary Relationship Types: Create a new relation for the n-ary relationship, including the primary keys of all participating entities as foreign keys.
  • Options for Mapping Specialization or Generalization:
    • Multiple relations - Superclass and subclasses.
    • Multiple relations - Subclass relations only
    • Single relation with one type attribute
    • Single relation with multiple type attributes.
  • Mapping of Union Types (Categories): Specify a new key attribute (surrogate key) when the defining superclasses have different keys.

Preparatory Questions and Answers

  • In which of the following, a separate schema is created consisting of that attribute and the primary key of the entity set? A multivalued attribute of an entity set.
  • The minimum number of tables needed to represent M, N, P, R1, R2 is 3
  • {M1, P1, N1} is a correct attribute set for one of the tables for the correct answer to the above question.
  • Minimum number of tables required to represent this situation in the relational model is 3
  • Min 1 and max 3. What is the min and max number of tables required to convert an ER diagram with 2 entities and 1 relationship between them with partial participation constraints of both entities?

Experiment 3: SQL Integrity Constraints

  • Objective is to apply SQL integrity constraints for the COMPANY database, based on given DDL statements.
  • The program outcome is to understand database creation and the application of various integrity constraints such as primary key, foreign key, unique key, NOT NULL, default, and CHECK.
  • Implement the following types of integrity constraints: Primary Key, Foreign Key, Unique, Default, Auto-increment, Check, Not Null

Types of Integrity Constraints

  • Primary Key: Uniquely identifies each row in a table; cannot be duplicate or null.
  • Foreign Key: Establishes a relationship between columns in one or more tables; references the primary key in another table.
  • NOT NULL: Ensures a column cannot contain a null value.
  • Unique Key: Ensures that a column or group of columns has a distinct value for each row; allows one null value.
  • Check Constraint: Defines a business rule on a column; all rows must satisfy this rule.

Syntax Examples

  • Primary Key (column level): column name datatype [CONSTRAINT constraint_name] PRIMARY KEY
  • Primary Key (table level): [CONSTRAINT constraint_name] PRIMARY KEY (column_name1, column_name2, ...)
  • Foreign Key (column level): [CONSTRAINT constraint_name] REFERENCES Referenced_Table_name(column_name)
  • Foreign Key (table level): [CONSTRAINT constraint_name] FOREIGN KEY(column_name) REFERENCES referenced_table_name(column_name);
  • Not Null: [CONSTRAINT constraint name] NOT NULL
  • Unique Key (column level): [CONSTRAINT constraint_name] UNIQUE
  • Unique Key (table level): [CONSTRAINT constraint_name] UNIQUE(column_name)
  • Check Constraint: [CONSTRAINT constraint_name] CHECK (condition)

Rules for Defining Primary Key

  • No two rows can have the same primary key value.
  • Every row must have a primary key value.
  • The primary key field cannot be null.
  • The primary key value cannot be modified if any foreign key refers to that primary key.

Preparatory Questions and Answers

  • If data in r1 and r2 satisfy referential integrity constraints, which of the following is ALWAYS TRUE? B
  • S1 is FALSE and S2 is TRUE: Given the following statements: S1: A foreign key declaration can always be replaced by an equivalent check assertion in SQL. S2: Given the table R(a,b,c) where a and b together form the primary key, the following is a valid table definition.
  • Which of the following is not an integrity constraint? Positive
  • In order to ensure that the value of budget is non-negative which of the following should be used? Check(budget>=0)

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Like This

Use Quizgecko on...
Browser
Browser