DBMS Assignment 1
DBMS Assignment 1
Set-I
1. What do you mean by cardinality? What are the different types of Cardinalities in RDBMS?
Explain by giving suitable example.
Cardinality in the context of relational database management systems (RDBMS) refers to
the uniqueness of data values that exist in a particular column of a database table. It
describes the relationship between two tables or entities in terms of how many instances of
one entity are associated with the other.
Types of Cardinality:
1. **One-to-One (1:1)**: A single entity instance in one table is related to a single entity
instance in another table.
Example: A person can have only one passport.
2. **One-to-Many (1:N)**: A single entity instance in one table can be related to multiple
entity instances in another table.
Example: A teacher can teach multiple students.
3. **Many-to-Many (M:N)**: Multiple instances in one table are related to multiple instances
in another table.
Example: Students can enroll in multiple courses, and each course can have multiple
students.
2. What do you mean by Entity Integrity Constraint and Referential Integrity Constraint?
Explain by giving suitable example.
**Entity Integrity Constraint** ensures that each table has a primary key and that the value
of the primary key is unique and not null. This guarantees that every record in the table is
uniquely identifiable.
Example: In a Student table, the 'Student_ID' column serves as the primary key.
**Referential Integrity Constraint** ensures that foreign key values in a table must either
match primary key values in the referenced table or be null. This maintains consistency
between related tables.
Example: In an Enrollment table, the 'Course_ID' foreign key must match the 'Course_ID' in
the Courses table.
3. Explain the important properties of transactions that a DBMS must ensure to maintain data
in the face of concurrent access and system failures.
Transactions in DBMS must satisfy the ACID properties to ensure reliability and consistency
of data during concurrent access and in case of system failures:
1. **Atomicity**: Ensures that a transaction is treated as a single unit, which either
completes entirely or does not happen at all.
Example: In a fund transfer, the amount is debited from one account and credited to
another. If any part fails, the transaction is rolled back.
2. **Consistency**: Ensures that a transaction transforms the database from one consistent
state to another.
Example: After a transaction, the total balance in all accounts remains unchanged.
4. **Durability**: Ensures that once a transaction is committed, the changes are permanent,
even in case of system failures.
Example: After updating a record, the changes persist even if the system crashes.
Set-II
1. Discuss different Operations in Relational Algebra? Explain each operation by giving suitable
example.
Relational Algebra is a procedural query language used to retrieve data from a database. It
consists of several operations:
1. **Selection (σ)**: Retrieves rows from a table that satisfy a given condition.
Example: σ(Age > 30)(Employee)
3. **Union (∪)**: Combines the results of two relations and removes duplicates.
Example: R1 ∪ R2
4. **Set Difference (-)**: Retrieves rows present in one relation but not in the other.
Example: R1 - R2
5. **Cartesian Product (×)**: Combines each row of one relation with every row of another.
Example: R1 × R2
2. **Second Normal Form (2NF)**: Builds on 1NF by ensuring that all non-key attributes are
fully functionally dependent on the primary key.
Example: In a Student table, 'Course_Name' depends on 'Course_ID' rather than
'Student_ID'.
3. **Third Normal Form (3NF)**: Ensures that no transitive dependencies exist. Non-key
attributes must depend only on the primary key.
Example: If 'Department_Name' depends on 'Department_ID' and 'Employee_ID', it should
be moved to a separate table.
3. What do you mean by Fragmentation? What are the different types of Fragmentation?
Explain by giving suitable example.
Fragmentation in DBMS refers to the process of dividing a database into smaller pieces or
fragments to improve performance and ensure data distribution in distributed database
systems. It allows efficient query processing by storing related data close to its point of use.
Types of Fragmentation:
1. **Horizontal Fragmentation**: Divides a table into rows based on specific criteria. Each
fragment contains a subset of rows from the original table.
Example: A 'Customer' table is fragmented by region into 'North_Customers' and
'South_Customers'.
2. **Vertical Fragmentation**: Divides a table into columns. Each fragment contains a subset
of columns and a copy of the primary key to ensure reconstruction.
Example: An 'Employee' table is split into 'Employee_Personal_Details' and
'Employee_Job_Details'.
3. **Hybrid Fragmentation**: Combines horizontal and vertical fragmentation. Rows are
first divided horizontally, and then columns are divided vertically.
Example: A 'Product' table is fragmented by category (horizontal) and then split by
attributes like price and supplier (vertical).