Midsem Exam Dbe
Midsem Exam Dbe
Unit-1
2 marks:
Data Models:
1. Hierarchical Model - Data is organized in a tree-like structure.
2. Network Model - Data is organized in a graph, allowing multiple parent-child relationships.
3. Relational Model - Data is organized in tables (relations).
4. Object-Oriented Model - Data is stored as objects, similar to programming languages.
5. (a) Draw ER diagram for Ternary Relationship set with suitable example? [5M]
Answer:
A Ternary Relationship involves three entities, such as a *Supplier*, *Part*, and *Project* where each supplier
supplies parts for a specific project.
*(Provide an ER diagram showing entities Supplier, Part, and Project connected in a ternary relationship.)*
(b) Discuss about key constraints for Ternary Relationships? [5M]
Answer:
Key Constraints for Ternary Relationships specify unique combinations within the relationship. For example, in the
Supplier-Part-Project relationship, a specific supplier can supply a unique part to only one project.
6. Draw the ER diagram for a company needs to store information about employees, departments, and children of
employees. [10M]
*(Provide an ER diagram as described with entities for Employees, Departments, and Children, showing primary keys,
relationships, and unique identifiers for children by parent.)*
8. Write about logical database design (ER to Relational) with suitable examples? [10M]
Answer:
Logical Database Design converts ER models to relational tables:
1. Entities become tables, and attributes become columns.
2. Relationships are represented by foreign keys.
Example:
1. Entity `Employee` (EmployeeID, Name, DepartmentID).
2. Relationship `WorksIn` is mapped by placing `DepartmentID` as a foreign key in `Employee`.
The Architecture of Database includes the three-tier structure (External, Conceptual, and Internal Levels).
10. Create tables for a college database with Employee and Department and explain referential integrity
constraints. [10M]
Answer:
Employee Table: Columns - empno (PK), empname, basic, hra, da, deductions, gross, net, dob.
Department Table: Columns - deptno (PK), deptname, description.
Referential Integrity: `deptno` in `Employee` references `deptno` in `Department`, ensuring that each employee is
assigned to a valid department.
Unit-2
2marks
1. Write query for finding the age of the youngest sailor who is eligible to vote for each rating level with at least
two such sailors. [2M]
Answer:
sql
SELECT rating, MIN(age) AS youngest_age
FROM Sailors
WHERE age >= 18
GROUP BY rating
HAVING COUNT(sid) >= 2;
This query finds the minimum age for each rating level where there are at least two sailors aged 18 or older.
The `SELECT` statement retrieves columns, `FROM` specifies the table, `WHERE` filters rows, `GROUP BY` groups
rows, and `ORDER BY` sorts the output.
10 marks
1) a) Explain in detail about nested queries. [5M]
Answer:
A nested query, also known as a subquery, is a query embedded within another SQL query. Nested queries can be
used in various places such as SELECT, INSERT, UPDATE, or DELETE statements. They provide a way to perform more
complex operations by allowing you to filter data based on results from another query.
Example:
sql
SELECT employee_id, employee_name
FROM employees
WHERE department_id IN (
SELECT department_id
FROM departments
WHERE location_id = 1000
);
In this example, the inner query retrieves all department IDs located at location 1000. The outer query then retrieves
the employee IDs and names of those who work in those departments.
Answer:
Aggregate operators perform calculations on a set of values and return a single value. Common aggregate functions
in SQL include:
2) Write about relational algebra? Discuss about different operators used in algebra. [10M]
Answer:
Relational algebra is a formal system used for manipulating and querying relational data. It consists of a set of
operations that take one or two relations as input and produce a new relation as output.
4. Difference (-): Returns tuples in one relation that are not in another.
- Example: employees_1 - employees_2
Answer:
| Feature | Relational Algebra | Relational Calculus |
||--|--|
| Nature | Procedural (describes how to obtain results) | Declarative (describes what results to obtain) |
| Expressions | Uses a set of operators to combine relations | Uses predicates to define desired properties |
| Complexity | Generally more complex for complex queries | Often simpler and more intuitive |
| Data Retrieval | Explicitly defines steps to retrieve data | Specifies conditions that must be satisfied for data
retrieval |
Answer:
The expressive power of a query language refers to its ability to articulate various data retrieval tasks. Both relational
algebra and relational calculus can express the same queries, but they do so in different ways:
- Relational Algebra: It is strong in defining operations through a series of steps, making it well-suited for procedural
implementations. Users must specify exactly how to manipulate the data.
- Relational Calculus: It allows users to state what data they want without specifying how to retrieve it. This flexibility
makes it easier to express complex queries using logical conditions.
Both have equivalent expressive power, meaning any query expressible in relational algebra can also be expressed in
relational calculus and vice versa.
4) What are the variations in relational calculus? Explain with examples. [10M]
Answer:
Relational calculus has two primary variations: Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC).
1. Tuple Relational Calculus (TRC): In TRC, queries are expressed using tuple variables.
- Example:
This expression retrieves all tuples from the `employees` relation where the salary is greater than 50,000.
2. Domain Relational Calculus (DRC): In DRC, queries are expressed using domain variables.
- Example:
This expression retrieves names and salaries of employees with a salary greater than 50,000.
Both variations allow users to specify conditions and retrieve data without specifying how to execute the queries.
5) What is a join operator? Explain about conditional join and natural join with syntax and example. [10M]
Answer:
A join operator combines rows from two or more tables based on a related column between them.
- Conditional Join: Combines rows based on a specified condition using the `ON` clause.
- Syntax:
sql
SELECT a.column1, b.column2
FROM tableA a
JOIN tableB b ON a.common_column = b.common_column;
- Example:
sql
SELECT e.employee_id, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id;
- Natural Join: Automatically combines rows from two tables based on columns with the same name and datatype. It
eliminates duplicate columns in the result.
- Syntax:
sql
SELECT *
FROM tableA NATURAL JOIN tableB;
- Example:
sql
SELECT *
FROM employees NATURAL JOIN departments;
6) How to list and update row in a table? Explain with syntax and examples. [10M]
Answer:
- Listing Rows: Use the `SELECT` statement to retrieve data from a table.
- Syntax:
sql
SELECT column1, column2
FROM table_name;
- Example:
sql
SELECT employee_id, employee_name
FROM employees;
- Example:
sql
UPDATE employees
SET salary = salary * 1.1
WHERE department_id = 10;
7) What is meant by integrity constraint? Write about complex integrity constraints in SQL. [10M]
Answer:
Integrity constraints are rules that ensure the accuracy and consistency of data in a relational database. They prevent
invalid data entry and maintain relationships between tables.
4. Check Constraint: Ensures that all values in a column satisfy a specific condition.
- Example:
sql
CREATE TABLE employees (
employee_id INT,
salary DECIMAL CHECK (salary > 0)
);
8) How can we compare using null values? Explain about logical connectives with examples. [10M]
Answer:
In SQL, comparing NULL values requires special handling because NULL represents an unknown value. You cannot use
regular comparison operators (like `=`, `<`, `>`) to check for NULL. Instead, you use the `IS NULL` or `IS NOT NULL`
constructs.
- Example:
sql
SELECT employee_id, employee_name
FROM employees
WHERE manager_id IS NULL;
This query retrieves all employees who do not have a manager (i.e., their `manager_id` is NULL).
Logical Connectives:
Logical connectives allow you to combine multiple conditions in SQL queries. The common logical connectives are:
:
sql
SELECT *
FROM employees
WHERE department_id = 10 AND salary > 50000;
Answer:
Outer joins retrieve matching rows from both tables and include non-matching rows from one or both tables.
1. Left Outer Join: Retrieves all rows from the left table and matching rows from the right table. Non-matching rows
from the right table are filled with NULL.
- Example:
sql
SELECT e.employee_id, d.department_name
FROM employees e
LEFT JOIN departments d ON e.department_id = d.department_id;
2. Right Outer Join: Retrieves all rows from the right table and matching rows from the left table. Non-matching rows
from the left table are filled with NULL.
- Example:
sql
SELECT e.employee_id, d.department_name
FROM employees e
RIGHT JOIN departments d ON e.department_id = d.department_id;
3. Full Outer Join: Retrieves all rows from both tables, filling with NULL where there are no matches.
- Example:
sql
SELECT e.employee_id, d.department_name
FROM employees e
FULL OUTER JOIN departments d ON e.department_id = d.department_id;
Answer:
Triggers are special stored procedures that automatically execute in response to certain events on a particular table
in a database, such as INSERT, UPDATE, or DELETE operations. They are used to enforce business rules and maintain
data integrity.
Types of Triggers:
Active Databases: An active database is one that incorporates event-driven features, allowing it to respond
automatically to changes in the data. Triggers are a key aspect of active databases, making them dynamic and
capable of enforcing rules and constraints automatically.
10) Explain Aggregate Operators with examples. [10M]
Answer:
Aggregate operators in SQL are functions that perform calculations on multiple rows of a table to return a single
value. They are often used with the `GROUP BY` clause to summarize data.
This query counts the number of employees in each department and calculates their average salary.
10marks
1) a) Explain in detail about nested queries. [5M]
Answer:
A nested query, also known as a subquery, is a query embedded within another SQL query. Nested queries can be
used in various places such as SELECT, INSERT, UPDATE, or DELETE statements. They provide a way to perform more
complex operations by allowing you to filter data based on results from another query.
Example:
sql
SELECT employee_id, employee_name
FROM employees
WHERE department_id IN (
SELECT department_id
FROM departments
WHERE location_id = 1000
);
In this example, the inner query retrieves all department IDs located at location 1000. The outer query then retrieves
the employee IDs and names of those who work in those departments.
Answer:
Aggregate operators perform calculations on a set of values and return a single value. Common aggregate functions
in SQL include:
Answer:
Relational algebra is a formal system used for manipulating and querying relational data. It consists of a set of
operations that take one or two relations as input and produce a new relation as output.
4. Difference (-): Returns tuples in one relation that are not in another.
- Example: employees_1 - employees_2
Answer:
| Feature | Relational Algebra | Relational Calculus |
||--|--|
| Nature | Procedural (describes how to obtain results) | Declarative (describes what results to obtain) |
| Expressions | Uses a set of operators to combine relations | Uses predicates to define desired properties |
| Complexity | Generally more complex for complex queries | Often simpler and more intuitive |
| Data Retrieval | Explicitly defines steps to retrieve data | Specifies conditions that must be satisfied for data
retrieval |
Answer:
The expressive power of a query language refers to its ability to articulate various data retrieval tasks. Both relational
algebra and relational calculus can express the same queries, but they do so in different ways:
- Relational Algebra: It is strong in defining operations through a series of steps, making it well-suited for procedural
implementations. Users must specify exactly how to manipulate the data.
- Relational Calculus: It allows users to state what data they want without specifying how to retrieve it. This flexibility
makes it easier to express complex queries using logical conditions.
Both have equivalent expressive power, meaning any query expressible in relational algebra can also be expressed in
relational calculus and vice versa.
4) What are the variations in relational calculus? Explain with examples. [10M]
Answer:
Relational calculus has two primary variations: Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC).
1. Tuple Relational Calculus (TRC): In TRC, queries are expressed using tuple variables.
- Example:
This expression retrieves all tuples from the `employees` relation where the salary is greater than 50,000.
2. Domain Relational Calculus (DRC): In DRC, queries are expressed using domain variables.
- Example:
This expression retrieves names and salaries of employees with a salary greater than 50,000.
Both variations allow users to specify conditions and retrieve data without specifying how to execute the queries.
5) What is a join operator? Explain about conditional join and natural join with syntax and example. [10M]
Answer:
A join operator combines rows from two or more tables based on a related column between them.
- Conditional Join: Combines rows based on a specified condition using the `ON` clause.
- Syntax:
sql
SELECT a.column1, b.column2
FROM tableA a
JOIN tableB b ON a.common_column = b.common_column;
- Example:
sql
SELECT e.employee_id, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id;
- Natural Join: Automatically combines rows from two tables based on columns with the same name and datatype. It
eliminates duplicate columns in the result.
- Syntax:
sql
SELECT *
FROM tableA NATURAL JOIN tableB;
- Example:
sql
SELECT *
FROM employees NATURAL JOIN departments;
6) How to list and update row in a table? Explain with syntax and examples. [10M]
Answer:
- Listing Rows: Use the `SELECT` statement to retrieve data from a table.
- Syntax:
sql
SELECT column1, column2
FROM table_name;
- Example:
sql
SELECT employee_id, employee_name
FROM employees;
- Example:
sql
UPDATE employees
SET salary = salary * 1.1
WHERE department_id = 10;
7) What is meant by integrity constraint? Write about complex integrity constraints in SQL. [10M]
Answer:
Integrity constraints are rules that ensure the accuracy and consistency of data in a relational database. They prevent
invalid data entry and maintain relationships between tables.
4. Check Constraint: Ensures that all values in a column satisfy a specific condition.
- Example:
sql
CREATE TABLE employees (
employee_id INT,
salary DECIMAL CHECK (salary > 0)
);
8) How can we compare using null values? Explain about logical connectives with examples. [10M]
Answer:
In SQL, comparing NULL values requires special handling because NULL represents an unknown value. You cannot use
regular comparison operators (like `=`, `<`, `>`) to check for NULL. Instead, you use the `IS NULL` or `IS NOT NULL`
constructs.
- Example:
sql
SELECT employee_id, employee_name
FROM employees
WHERE manager_id IS NULL;
This query retrieves all employees who do not have a manager (i.e., their `manager_id` is NULL).
Logical Connectives:
Logical connectives allow you to combine multiple conditions in SQL queries. The common logical connectives are:
:
sql
SELECT *
FROM employees
WHERE department_id = 10 AND salary > 50000;
Answer:
Outer joins retrieve matching rows from both tables and include non-matching rows from one or both tables.
1. Left Outer Join: Retrieves all rows from the left table and matching rows from the right table. Non-matching rows
from the right table are filled with NULL.
- Example:
sql
SELECT e.employee_id, d.department_name
FROM employees e
LEFT JOIN departments d ON e.department_id = d.department_id;
2. Right Outer Join: Retrieves all rows from the right table and matching rows from the left table. Non-matching rows
from the left table are filled with NULL.
- Example:
sql
SELECT e.employee_id, d.department_name
FROM employees e
RIGHT JOIN departments d ON e.department_id = d.department_id;
3. Full Outer Join: Retrieves all rows from both tables, filling with NULL where there are no matches.
- Example:
sql
SELECT e.employee_id, d.department_name
FROM employees e
FULL OUTER JOIN departments d ON e.department_id = d.department_id;
Answer:
Triggers are special stored procedures that automatically execute in response to certain events on a particular table
in a database, such as INSERT, UPDATE, or DELETE operations. They are used to enforce business rules and maintain
data integrity.
Types of Triggers:
Active Databases: An active database is one that incorporates event-driven features, allowing it to respond
automatically to changes in the data. Triggers are a key aspect of active databases, making them dynamic and
capable of enforcing rules and constraints automatically.
Answer:
Aggregate operators in SQL are functions that perform calculations on multiple rows of a table to return a single
value. They are often used with the `GROUP BY` clause to summarize data.
This query counts the number of employees in each department and calculates their average salary.
Unit-3
2marks
1. What is meant by attribute closure? Explain. [2M]
Answer:
Attribute closure refers to the set of attributes that can be functionally determined from a given set of attributes
under a specified set of functional dependencies. It is denoted as (X^+) for a set of attributes (X). To compute the
closure, we start with (X) and iteratively add attributes that can be derived from the functional dependencies until no
more attributes can be added.
Example: Given attributes (A) and functional dependencies (A ->B) and (B ->C), the closure ( {A}^+ = {A, B, C} ).
Answer:
Functional dependencies (FDs) can be classified into several types based on their characteristics:
Answer:
The properties of decomposition in database design are:
1. Lossless Decomposition: Ensures that no information is lost when a relation is decomposed into smaller relations.
It allows the original relation to be reconstructed without any loss.
2. Dependency Preservation: Ensures that all functional dependencies are preserved after decomposition. This
means that the functional dependencies can still be enforced in the decomposed relations without the need for
joining them back.
3. Redundancy Reduction: Aims to minimize data redundancy, leading to efficient storage and update operations.
4. Prove that any relation schema with two attributes is BCNF. [2M]
Answer:
A relation schema is in Boyce-Codd Normal Form (BCNF) if for every functional dependency (X ->Y), (X) is a superkey.
5. Discuss about super key and candidate key in functional dependency with suitable example. [2M]
Answer:
- Super Key: A super key is a set of one or more attributes that can uniquely identify a tuple in a relation. It may
contain extra attributes that are not necessary for unique identification.
Example: In a relation with attributes ( {A, B, C} ), the set ( {A, B} ) can be a super key if it uniquely identifies tuples.
- Candidate Key: A candidate key is a minimal super key, meaning that no subset of the candidate key can uniquely
identify a tuple.
Example: If ( {A} ) is the only attribute that can uniquely identify tuples and no subset of ( {A} ) can do so, then ( {A} )
is a candidate key.
Answer:
Lossless-join decomposition is a property of database normalization that ensures the original relation can be
reconstructed from the decomposed relations without any loss of information. For a decomposition of a relation (R)
into (R1) and (R2), it must hold that the natural join of (R1) and (R2) results in the original relation (R). This is critical
to maintain data integrity and consistency after decomposition.
7. What are axioms? [2M]
Answer:
Axioms in the context of functional dependencies are rules or principles that are accepted without proof and serve as
a foundation for reasoning about the dependencies in a database schema. They provide a basis for deriving all
functional dependencies in a given relation. The common axioms include:
Answer:
SQL domain types define the type of data that can be stored in a column of a database table. Common SQL domain
types include:
Answer:
Triggers are necessary for several reasons in database management:
1. Automated Actions: They allow for automatic execution of predefined actions in response to certain events
(INSERT, UPDATE, DELETE) on a table.
2. Data Integrity: Triggers help maintain data integrity by enforcing rules, constraints, and business logic
automatically, ensuring that the data adheres to certain conditions without manual intervention.
3. Auditing and Logging: They can be used to automatically log changes to data for auditing purposes, keeping track
of who changed what and when.
10. What is meant by computing the closure of a set of functional dependency? [2M]
Answer:
Computing the closure of a set of functional dependencies involves determining all attributes that can be functionally
determined from a given set of attributes using the provided functional dependencies. It helps identify all possible
attribute relationships in a relation schema. The closure is denoted as (X^+) for a set of attributes (X) and is computed
by iteratively applying the functional dependencies until no new attributes can be added.
Example: Given (F = {A ->B, B ->C}) and (X = {A}), the closure ( {A}^+ = {A, B, C} ).
10 marks
1) a) Differentiate BCNF with 3rd normal form. [7M]
Answer:
Boyce-Codd Normal Form (BCNF) and Third Normal Form (3NF) are both normalization forms used to reduce
redundancy in relational databases. The key differences are:
Answer:
Denormalization is the process of intentionally introducing redundancy into a database by merging tables or adding
redundant data to improve read performance. It is used to enhance query performance at the cost of additional
complexity in maintaining data consistency. While normalization reduces redundancy, denormalization can simplify
complex queries by reducing the number of joins needed.
Example: In a normalized schema, customer and order data might be stored in separate tables. Denormalization
might involve adding customer information directly into the order table to reduce the need for joins when querying
order details.
2) What are different types of normalization? Also explain the difference between BCNF and 3NF. [10 M]
Answer:
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. The
different types of normalization forms include:
1. First Normal Form (1NF): Eliminates duplicate columns from the same table and ensures that each column contains
atomic (indivisible) values.
2. Second Normal Form (2NF): Achieves 1NF and removes partial dependencies; every non-key attribute must
depend on the entire primary key.
3. Third Normal Form (3NF): Achieves 2NF and removes transitive dependencies; no non-key attribute depends on
another non-key attribute.
4. Boyce-Codd Normal Form (BCNF): A stricter version of 3NF where for every functional dependency (X -> Y), (X)
must be a superkey.
Answer:
To prove that a relation in Fourth Normal Form (4NF) must also be in Boyce-Codd Normal Form (BCNF):
1. 4NF Definition: A relation is in 4NF if it is in BCNF and has no multivalued dependencies other than a trivial
dependency.
2. If a relation satisfies the 4NF condition, it is already in BCNF by definition since 4NF requires that all functional
dependencies must have a superkey as the left-hand side.
Thus, a relation that is in 4NF is necessarily in BCNF because it satisfies the stricter conditions required for BCNF.
Answer:
Fourth Normal Form (4NF) is a level of database normalization that extends BCNF by eliminating multivalued
dependencies. A relation is in 4NF if:
1. It is in BCNF.
2. It contains no multivalued dependencies, unless they are trivial.
This relation has a multivalued dependency (A -> -> B) and (A -> -> C), which violates 4NF. To convert it to 4NF, we can
decompose it into two relations:
- (R1(A, B))
- (R2(A, C))
Both relations now do not exhibit multivalued dependencies, thus achieving 4NF.
4) a) Define BCNF. How does BCNF differ from 3NF? Explain with example. [6M]
Answer:
Boyce-Codd Normal Form (BCNF) is a normalization form used in database design to reduce redundancy. A relation is
in BCNF if for every functional dependency (X -> Y), (X) is a superkey.
Example:
Consider a relation (R(A, B, C)):
- Functional dependencies: (A -> B) and (B -> C).
- If (A) is the primary key, (R) is in 3NF but not in BCNF because (B) (a non-key attribute) determines (C).
Answer:
Third Normal Form (3NF) is a normalization level that aims to eliminate transitive dependencies. A relation is in 3NF
if:
1. It is in Second Normal Form (2NF).
2. There are no transitive dependencies, meaning no non-prime attribute depends on another non-prime attribute.
Example:
Consider a relation (R(A, B, C)):
- Functional dependencies: (A -> B) and (B -> C).
- Here, (A) is the primary key, and (C) is transitively dependent on (A) through (B).
5) a) Compare and contrast between third normal form and BCNF. [5M]
Answer:
| Aspect | Third Normal Form (3NF) | Boyce-Codd Normal Form (BCNF) |
|-|--|--|
| Definition | A relation is in 3NF if it is in 2NF and has no transitive dependencies. | A relation is in BCNF if
every functional dependency (X -> Y) has (X) as a superkey. |
| Strength | Less strict; allows some redundancy. | Stricter; eliminates all redundancy due to
functional dependencies. |
| Example | Relation (R(A, B, C)) with (A -> B) and (B -> C) (3NF but not BCNF). | Relation (R(A, B)) with (A -> B)
(if (A) is a superkey, then it is in BCNF). |
Answer:
Loss-less join decomposition is a property of database normalization that ensures that no information is lost when
decomposing a relation into two or more relations. For a decomposition of a relation (R) into (R1) and (R2), it must
hold that the natural join of (R1) and (R2) produces the original relation (R).
Example:
Consider a relation (R(A, B, C)) with functional dependency (A -> B).
- Decompose (R) into:
- (R1(A, B))
- (R2(A, C))
This results in the original relation (R(A, B, C)), ensuring a loss-less join.
6) a) Discuss multivalued dependencies with fourth normal form with an example. [5M]
Answer:
Multivalued dependencies occur when one attribute in a relation determines multiple values of another attribute,
independent of other attributes. A relation is in Fourth Normal Form (4NF) if it is in BCNF and has no non-trivial
multivalued dependencies.
Example
Consider a relation (R(A, B, C)):
- Multivalued dependency: (A ->-> B) (A can have multiple B values) and (A ->-> C) (A can have multiple C values).
To achieve 4NF, we decompose (R) into:
- (R1(A, B))
- (R2(A, C))
Both relations now avoid multivalued dependencies.
b) Explain join dependencies with fifth normal form with an example. [5M]
Answer:
Join dependencies occur when a relation can be reconstructed by joining multiple relations. A relation is in Fifth
Normal Form (5NF) if it is in 4NF and every join dependency in the relation is implied by the candidate keys.
Example:
Consider a relation (R(A, B, C)) with the following functional dependencies:
- (A -> B)
- (A -> C)
This relation can be decomposed into:
- (R1(A, B))
- (R2(A, C))
Now, any join of (R1) and (R2) yields the original relation (R). Thus, the relation is in 5NF because the join dependency
is preserved.
7) Define normalization. List and Explain different normal forms with examples. [10M]
Answer:
Normalization is the process of organizing a database to reduce redundancy and improve data integrity. It involves
dividing a database into two or more tables and defining relationships between them.
Different normal forms include:
1. First Normal Form (1NF): A relation is in 1NF if it contains only atomic (indivisible) values.
- Example:
Relation (R(A, B)) where (A) has values (1, 2) and (B) has (a, b) is not in 1NF. Transform it to (R(A, B)) with rows (1,
a), (1, b), (2, a), (2, b).
2. Second Normal Form (2NF): A relation is in 2NF if it is in 1NF and has no partial dependencies.
- Example:
Relation (R(A, B, C)) with (A) as a composite key (A, B) → C is in 2NF if (C) depends on both (A) and (B) rather than
just part of it.
3. Third Normal Form (3NF): A relation is in 3NF if it is in 2NF and has no transitive dependencies.
- Example:
Relation (R(A, B, C)) with (A -> B) and (B -> C) needs decomposition into (R1(A, B)) and (R2(B, C)).
4. Boyce-Codd Normal Form (BCNF): A relation is in BCNF if for every functional dependency (X -> Y), (X) is a
superkey.
- Example:
Relation (R(A, B)) where (A -> B) and (A) is the primary key is in BCNF.
5. Fourth Normal Form (4NF): A relation is in 4NF if it is in BCNF and has no multivalued dependencies.
- Example:
Relation (R(A, B, C)) with multivalued dependencies can be decomposed into (R1(A, B)) and (R2(A, C)).
6. Fifth Normal Form (5NF): A relation is in 5NF if it is in 4NF and all join dependencies are implied by the candidate
keys.
- Example:
Relation (R(A, B, C)) with dependencies can be decomposed into (R1(A, B)) and (R2(A, C)) and still retains its join
dependencies.
8) Explain about schema refinement in database design. [10M]
Answer:
Schema refinement in database design is the process of adjusting a database schema to achieve a balance between
normalization and performance. The goals of schema refinement include:
1. Reducing Redundancy: Eliminating duplicated data by normalizing the database to appropriate normal forms.
2. Improving Data Integrity: Ensuring that relationships between data are correctly represented, which prevents
anomalies during data manipulation.
3. Enhancing Performance: In some cases, overly normalized schemas may lead to complex queries and performance
issues. Therefore, denormalization might be necessary to improve read performance.
Answer:
Problems related to decomposition in databases include:
1. Loss of Information: If a decomposition is not lossless, some information may be lost, making it impossible to
reconstruct the original relation from the decomposed tables.
2. Update Anomalies: Decomposing relations can lead to complexities during updates, especially if data is duplicated
across multiple tables. This can lead to inconsistencies if updates are not applied uniformly.
3. Performance Issues: Frequent joins required to reconstruct data from decomposed tables can lead to performance
degradation, especially in read-heavy applications.
10) a) Compare and contrast between First normal form and second normal form. [5M]
Answer:
| Aspect | First Normal Form (1NF) | Second Normal Form (2NF) |
||--|--|
| Definition | A relation is in 1NF if all attributes contain only atomic values. | A relation is in 2NF if it is in 1NF
and has no partial dependencies. |
| Redundancy | Allows duplicate rows; does not eliminate redundancy. | Reduces redundancy by ensuring no
partial dependencies exist. |
| Example | Relation (R(A, B)) with multiple values in a single cell is not in 1NF. | Relation (R(A, B, C)) with a
composite key (A, B) where C depends only on A is not in 2NF. |
The result will reconstruct the original relation (R(A, B, C)), ensuring a loss-less join.