9 Lecture
CS403
Midterm & Final Term Short Notes
Relationships
In the context of databases, a relationship refers to the association between entities. It describes how entities are related to each other and how they interact. Relationships can be of different types, such as one-to-one, one-to-many, and many
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
- In the context of databases, what is a relationship?
A) The physical structure of a database
B) The association between entities
C) The SQL query used to retrieve data
D) The primary key of a table
Answer: B) The association between entities
What are the different types of relationships in an Entity-Relationship Diagram (ERD)?
A) One-to-one, many-to-one, and many-to-many
B) One-to-many, many-to-many, and exclusive-or
C) Binary, ternary, and quaternary
D) Functional, multivalued, and join
Answer: B) One-to-many, many-to-many, and exclusive-or
What does the cardinality of a relationship in an ERD define?
A) The number of entities involved in the relationship
B) The types of attributes associated with the entities
C) The physical location of the entities in the database
D) The number of instances of an entity that can be associated with another entity
Answer: D) The number of instances of an entity that can be associated with another entity
What does the degree of a relationship in an ERD refer to?
A) The number of entities involved in the relationship
B) The types of attributes associated with the entities
C) The physical location of the entities in the database
D) The number of instances of an entity that can be associated with another entity
Answer: A) The number of entities involved in the relationship
Which of the following is an example of a one-to-many relationship in an ERD?
A) A department can have many employees, but an employee can belong to only one department
B) A customer can place many orders, and an order can have many line items
C) A student can attend many classes, and a class can have many students
D) A product can be sold at many stores, and a store can sell many products
Answer: A) A department can have many employees, but an employee can belong to only one department
Which of the following is an example of a many-to-many relationship in an ERD?
A) A department can have many employees, but an employee can belong to only one department
B) A customer can place many orders, and an order can have many line items
C) A student can attend many classes, and a class can have many students
D) A product can be sold at many stores, and a store can sell many products
Answer: C) A student can attend many classes, and a class can have many students
What is the purpose of a foreign key in a relationship?
A) To link two tables in a database
B) To ensure data consistency and referential integrity
C) To represent the association between entities in an ERD
D) To provide a unique identifier for each entity in a table
Answer: B) To ensure data consistency and referential integrity
What is the difference between a mandatory and optional relationship?
A) Mandatory relationships require at least one instance of an entity to be associated with another entity, while optional relationships do not.
B) Mandatory relationships involve two entities, while optional relationships involve three or more entities.
C) Mandatory relationships are represented using a solid line in an ERD, while optional relationships are represented using a dashed line.
D) Mandatory relationships are always one-to-many, while optional relationships can be one-to-one or many-to-many.
Answer: A) Mandatory relationships require at least one instance of an entity to be associated with another entity, while optional relationships do not.
What is the purpose of a junction table in a many-to-many relationship?
A) To store the attributes associated with each
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is a relationship in the context of a database? Answer: In a database, a relationship is a connection between two or more tables based on their columns. What are the different types of relationships in a database? Answer: The different types of relationships in a database are one-to-one, one-to-many, and many-to-many. What is a one-to-one relationship in a database? Answer: A one-to-one relationship is a relationship between two tables where each row in one table is related to one and only one row in the other table. What is a one-to-many relationship in a database? Answer: A one-to-many relationship is a relationship between two tables where each row in one table can be related to one or more rows in the other table. What is a many-to-many relationship in a database? Answer: A many-to-many relationship is a relationship between two tables where each row in one table can be related to one or more rows in the other table, and vice versa. What is a foreign key in a database? Answer: A foreign key is a column or a set of columns in one table that refers to the primary key of another table. What is referential integrity in a database? Answer: Referential integrity is a feature of a database that ensures that the relationships between tables are maintained by enforcing certain rules, such as preventing the deletion of a row in a table if it is referenced by another row in a different table. How do you represent a relationship in an entity-relationship diagram? Answer: A relationship in an entity-relationship diagram is represented by a line connecting the related tables, with the cardinality and optionality of the relationship indicated by symbols on the line. What is the difference between a strong and weak entity in a database? Answer: A strong entity is an entity that has a primary key, while a weak entity is an entity that depends on another entity for its existence and has a partial key. What is the purpose of a junction table in a many-to-many relationship? Answer: The purpose of a junction table in a many-to-many relationship is to connect the two related tables by storing the primary keys of each table as foreign keys in the junction table.