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
  1. 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
  1. 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.

In the context of databases, a relationship refers to how two or more tables in a database are connected or related to each other. Relationships can be classified into three types: one-to-one, one-to-many, and many-to-many. One-to-one relationships occur when each record in one table is related to only one record in another table. One-to-many relationships occur when each record in one table can be related to multiple records in another table. Many-to-many relationships occur when multiple records in one table can be related to multiple records in another table. Relationships are established through the use of keys, which are columns or sets of columns that uniquely identify each record in a table. Foreign keys are used to establish relationships between tables by referencing the primary key of another table. For example, a customer table may have a primary key of customer ID, and an orders table may have a foreign key of customer ID that references the customer table. The proper establishment and management of relationships is crucial in database design as it helps ensure data integrity and consistency. A well-designed database will have clearly defined relationships that are enforced through the use of constraints and rules to prevent data inconsistencies and errors. When designing relationships, it is important to consider factors such as data access patterns, performance, and scalability.