Podcast
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'?
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?
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?
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?
In a relational database, what is the purpose of a foreign key?
If an entity set does not have sufficient attributes to form a primary key, how is it termed?
If an entity set does not have sufficient attributes to form a primary key, how is it termed?
What does the cardinality ratio specify in the context of relationships between entities?
What does the cardinality ratio specify in the context of relationships between entities?
Which SQL constraint is used to enforce a specific rule on a column?
Which SQL constraint is used to enforce a specific rule on a column?
In ER modeling, what does total participation of an entity in a relationship mean?
In ER modeling, what does total participation of an entity in a relationship mean?
When mapping an M:N relationship between two entities E1 and E2 to a relational model, what is typically created?
When mapping an M:N relationship between two entities E1 and E2 to a relational model, what is typically created?
Which of the following is a recursive relationship?
Which of the following is a recursive relationship?
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?
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?
Which of the following is NOT a valid rule for defining a primary key?
Which of the following is NOT a valid rule for defining a primary key?
If a directed line (-->) exists from the relationship set 'advisor' to both entity sets 'instructor' and 'student', what cardinality does this indicate?
If a directed line (-->) exists from the relationship set 'advisor' to both entity sets 'instructor' and 'student', what cardinality does this indicate?
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?
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?
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?
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?
Which of the following SQL commands is used to add a new column to an existing table?
Which of the following SQL commands is used to add a new column to an existing table?
What does the term 'normalization' refer to in the context of database design?
What does the term 'normalization' refer to in the context of database design?
Which type of relationship requires the creation of a new table to properly implement it in a relational database?
Which type of relationship requires the creation of a new table to properly implement it in a relational database?
Using the following CREATE TABLE statement, what constraint can be used to make sure that the budget can never be below 0?
Using the following CREATE TABLE statement, what constraint can be used to make sure that the budget can never be below 0?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
In which of the following scenarios is a separate schema created, consisting of that attribute and the primary key of the entity set?
In which of the following scenarios is a separate schema created, consisting of that attribute and the primary key of the entity set?
Which of the following indicates the maximum number of entities that can be involved in a relationship?
Which of the following indicates the maximum number of entities that can be involved in a relationship?
Given the basic ER and relational models, which of the following is INCORRECT?
Given the basic ER and relational models, which of the following is INCORRECT?
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?
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?
What is the purpose of mapping EER model constructs to relations?
What is the purpose of mapping EER model constructs to relations?
Which type of integrity constraint is specifically designed to maintain the accuracy and consistency of data by ensuring that relationships between tables remain valid?
Which type of integrity constraint is specifically designed to maintain the accuracy and consistency of data by ensuring that relationships between tables remain valid?
What is the main purpose of creating an ER diagram?
What is the main purpose of creating an ER diagram?
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'?
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'?
What is a 'surrogate key' primarily used for when mapping union types (categories) in a database?
What is a 'surrogate key' primarily used for when mapping union types (categories) in a database?
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?
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?
In SQL, which constraint ensures that all values in a column are different?
In SQL, which constraint ensures that all values in a column are different?
State true or false: Every weak entity must be associated with an identifying entity.
State true or false: Every weak entity must be associated with an identifying entity.
Flashcards
Entity
Entity
A real-world object distinguishable from other objects, described using a set of attributes.
Entity Set
Entity Set
A collection of similar entities (e.g., all employees) with the same set of attributes and a key.
Attributes
Attributes
Properties used to describe an entity, such as Name, SSN, Address, or BirthDate for an EMPLOYEE entity.
Relationship
Relationship
Signup and view all the flashcards
Recursive Relationship
Recursive Relationship
Signup and view all the flashcards
Cardinality Ratio
Cardinality Ratio
Signup and view all the flashcards
Participation Constraints
Participation Constraints
Signup and view all the flashcards
Total Participation
Total Participation
Signup and view all the flashcards
Partial Participation
Partial Participation
Signup and view all the flashcards
Primary Key
Primary Key
Signup and view all the flashcards
Foreign Key
Foreign Key
Signup and view all the flashcards
NOT NULL Constraint
NOT NULL Constraint
Signup and view all the flashcards
Unique Key
Unique Key
Signup and view all the flashcards
Check Constraint
Check Constraint
Signup and view all the flashcards
Mapping Regular Entity Types
Mapping Regular Entity Types
Signup and view all the flashcards
Mapping Weak Entity Types
Mapping Weak Entity Types
Signup and view all the flashcards
Mapping Binary 1:1 Relation Types
Mapping Binary 1:1 Relation Types
Signup and view all the flashcards
Mapping Binary 1:N Relationship Types
Mapping Binary 1:N Relationship Types
Signup and view all the flashcards
Mapping Binary M:N Relationship Types
Mapping Binary M:N Relationship Types
Signup and view all the flashcards
Mapping Multi-valued attributes
Mapping Multi-valued attributes
Signup and view all the flashcards
Mapping of N-ary Relationship Types
Mapping of N-ary Relationship 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.