0% found this document useful (0 votes)
28 views21 pages

Branch: B. Tech Cys Subject: Dbms Subject Code: BTCS 505-18 Semester: 5th

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views21 pages

Branch: B. Tech Cys Subject: Dbms Subject Code: BTCS 505-18 Semester: 5th

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Branch: B.

Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

Sr. No. Marks Question CO Bloom’s Level

1 2 Define relational algebra. CO2 Remember


2 2 What is a tuple in relational CO2 Remember
calculus?
3 2 Mention any two DDL CO2 Remember
commands in SQL.
4 2 What is domain in database CO2 Remember
design?
5 2 Write any two SQL DML CO2 Remember
commands.
6 2 Define data dependency. CO2 Understand
7 2 What are Armstrong's CO2 Remember
axioms?
8 2 Name any two open-source CO2 Remember
DBMS.
9 2 Differentiate between DDL CO2 Understand
and DML.
10 2 What is a lossless CO2 Understand
decomposition?
11 2 Define join operation in CO2 Remember
relational algebra.
12 2 What is query equivalence? CO2 Remember
13 2 What is SQL3? CO2 Remember
14 2 Name any two commercial CO2 Remember
DBMS.
15 2 List any two join types in CO2 Remember
SQL.
16 2 What is a candidate key? CO2 Understand
17 2 Mention any two normal CO2 Remember
forms.
18 2 What is functional CO2 Understand
dependency?
19 2 Define query optimization. CO4 Remember
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

20 2 What is atomicity in a CO4 Remember


transaction?
21 5 Explain basic relational CO2 Understand
algebra operations with
examples.
22 5 Describe differences between CO2 Understand
tuple and domain relational
calculus.
23 5 Write and explain basic SQL CO2 Apply
DDL and DML statements.
24 5 Explain Armstrong’s axioms CO2 Understand
with use cases.
25 5 List and explain various CO2 Understand
types of joins with SQL
syntax.
26 5 Illustrate the concept of CO2 Apply
lossless decomposition with
example.
27 5 Describe domain and data CO2 Understand
dependency in relational
design.
28 5 Explain any three query CO4 Understand
optimization techniques.
29 5 Compare open-source vs CO2 Analyze
commercial DBMS with
examples.
30 5 Explain the ACID properties CO4 Understand
in database transactions.
31 8 Write SQL queries for a CO2 Apply
student database involving
SELECT, JOIN, GROUP
BY.
32 8 Solve queries using relational CO2 Apply
algebra for a given schema.
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

33 8 Design a database schema CO2 Create


and write SQL3 queries for
university application.
34 8 Normalize a given relation to CO2 Analyze
1NF, 2NF, and 3NF with
explanation.
35 8 Compare and contrast CO2 Analyze
relational algebra and SQL
with examples.
36 8 Analyze a case where CO2 Evaluate
dependency preservation and
lossless join conflict.
37 8 Explain join strategies used CO4 Understand
in query processing and their
performance.
38 8 Describe in detail any two CO4 Understand
query optimization
algorithms with example.
39 8 Evaluate SQL execution CO4 Evaluate
plans and discuss their
impact on performance.
40 8 Discuss how ACID CO4 Evaluate
properties are ensured in
multi-user database
environments.

Q1. Define relational algebra.


Relational algebra is a procedural query language that uses a set of operations (like select,
project, union, etc.) to manipulate relations (tables) and retrieve desired data from a relational
database.
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

Q2. What is a tuple in relational calculus?


A tuple is a single row in a relation. In tuple relational calculus, it represents a variable that
ranges over rows of a relation.
Q3. Mention any two DDL commands in SQL.
Two DDL (Data Definition Language) commands are:
● CREATE – to create tables
● ALTER – to modify table structure
Q4. What is domain in database design?
A domain is the set of permissible values that an attribute can hold. For example, an "Age"
attribute may have the domain of positive integers.
Q5. Write any two SQL DML commands.
Two DML (Data Manipulation Language) commands are:
● INSERT – to add records
● UPDATE – to modify existing records
Q6. Define data dependency.
Data dependency refers to the relationship between attributes such that one attribute's value
depends on another, typically represented as functional dependencies.
Q7. What are Armstrong's axioms?
Armstrong's axioms are a set of inference rules (reflexivity, augmentation, transitivity) used to
derive all functional dependencies from a given set.
Q8. Name any two open-source DBMS.
● MySQL
● PostgreSQL
Q9. Differentiate between DDL and DML.
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

● DDL is used to define and modify database schema (e.g., CREATE).


● DML is used to manipulate data within the schema (e.g., SELECT, INSERT).
Q10. What is a lossless decomposition?
Lossless decomposition ensures that when a relation is decomposed into two or more sub-
relations, the original relation can be reconstructed without any loss of information.
Q11. Define join operation in relational algebra.
Join is a binary operation that combines related tuples from two relations based on a common
attribute.
Q12. What is query equivalence?
Query equivalence means two queries return the same result set, even if written differently.
Q13. What is SQL3?
SQL3 is an extension of SQL that supports object-oriented features like user-defined types,
inheritance, and complex objects.
Q14. Name any two commercial DBMS.
● Oracle
● Microsoft SQL Server
Q15. List any two join types in SQL.
● INNER JOIN
● LEFT OUTER JOIN
Q16. What is a candidate key?
A candidate key is a minimal set of attributes that uniquely identify a tuple in a relation.
Q17. Mention any two normal forms.
● First Normal Form (1NF)
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

● Second Normal Form (2NF)


Q18. What is functional dependency?
Functional dependency is a constraint between two sets of attributes where one attribute uniquely
determines another.
Q19. Define query optimization.
Query optimization is the process of selecting the most efficient way to execute a given query by
the database engine.
Q20. What is atomicity in a transaction?
Atomicity ensures that all operations of a transaction are completed successfully or none at all,
preserving data consistency.
Q21. Explain basic relational algebra operations with examples.
Relational algebra is a procedural query language used to manipulate relations. Key operations
include:
1. Selection (σ) – Filters rows:
σ Dept = 'CSE' (Student) – selects students from CSE department.
2. Projection (π) – Selects specific columns:
π Name, Dept (Student) – shows only Name and Dept.
3. Union (∪) – Combines rows from two relations (duplicates removed):
Student1 ∪ Student2
4. Set Difference (−) – Rows in one relation but not in the other:
Student1 − Student2
5. Cartesian Product (×) – Pairs all tuples:
Student × Course
6. Rename (ρ) – Renames attributes or relation:
ρ(S, Student)
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

These operations form the basis of query processing in DBMS.

Q22. Describe differences between tuple and domain relational calculus.


Feature Tuple Relational Calculus (TRC) Domain Relational Calculus (DRC)

Syntax Uses tuple variables Uses domain variables

Representation Oriented on row-level data Oriented on attribute-level data

Example Query `{t t ∈ Student ∧ [Link] > 18}`

Expressiveness Same power as DRC Same power as TRC

Simplicity Easy for row-wise logic Easy for column-wise logic


Both are non-procedural query languages used to describe what data to retrieve, not how.

Q23. Write and explain basic SQL DDL and DML statements.
DDL Commands (structure-related):
● CREATE TABLE

CREATE TABLE Student (RollNo INT, Name VARCHAR(50));


● ALTER TABLE

ALTER TABLE Student ADD Age INT;


● DROP TABLE
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

DROP TABLE Student;


DML Commands (data-related):
● INSERT

INSERT INTO Student VALUES (101, 'Ravi');


● UPDATE

UPDATE Student SET Name = 'Amit' WHERE RollNo = 101;


● DELETE

DELETE FROM Student WHERE RollNo = 101;


These statements define and manipulate the structure and contents of tables.

Q24. Explain Armstrong’s axioms with use cases.


Armstrong’s Axioms are inference rules to derive functional dependencies (FDs):
1. Reflexivity: If Y ⊆ X, then X → Y
Example: {RollNo, Name} → RollNo

2. Augmentation: If X → Y, then XZ → YZ
Example: If RollNo → Name, then RollNo, Dept → Name, Dept
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

3. Transitivity: If X → Y and Y → Z, then X → Z


Example: RollNo → Name and Name → Email ⇒ RollNo → Email

These are foundational for normalization and ensuring data integrity.

Q25. List and explain various types of joins with SQL syntax.
1. INNER JOIN: Returns matching rows from both tables.

SELECT * FROM A INNER JOIN B ON [Link] = [Link];


2. LEFT JOIN (LEFT OUTER JOIN): All records from left, matched from right.

SELECT * FROM A LEFT JOIN B ON [Link] = [Link];


3. RIGHT JOIN (RIGHT OUTER JOIN): All from right, matched from left.
4. FULL JOIN (FULL OUTER JOIN): All from both with nulls where unmatched.
5. CROSS JOIN: Cartesian product – all combinations of rows.
Each join type serves specific needs in combining relational data.

Q26. Illustrate the concept of lossless decomposition with example.


A lossless decomposition ensures that no data is lost when a relation is split.
Example:
Let R(A, B, C) have FD: A → B
Decompose R into:
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

● R1(A, B)
● R2(A, C)
Natural Join:
R1 ⨝ R2 → gives back original relation R

This decomposition is lossless because A is a key in R1, satisfying the lossless join property.

Q27. Describe domain and data dependency in relational design.


Domain: Set of valid values an attribute can hold.
E.g.: Age domain = integers between 0–150.
Data Dependency: Relationship between attributes, often captured using functional
dependencies (FDs).
E.g.: RollNo → Name means Name depends on RollNo.

Understanding domains and dependencies ensures efficient database design, normalization,


and integrity.

Q28. Explain any three query optimization techniques.


1. Selection Pushdown: Apply selection early to reduce data processed.
E.g.: Move WHERE clause near source.
2. Join Reordering: Perform joins in most efficient sequence.
E.g.: Smaller tables first.
3. Index Usage: Use indexes to access data quickly instead of full scans.
These techniques help improve query execution time and resource efficiency.
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

Q29. Compare open-source vs commercial DBMS with examples.


Feature Open Source Commercial

Cost Free License fee required

Examples MySQL, PostgreSQL Oracle, MS SQL Server

Support Community based Professional support

Features Customizable Rich enterprise features

Scalability Moderate to High Very High


Open source is best for flexible, cost-effective projects. Commercial DBMS is ideal for
enterprise-scale, mission-critical systems.

Q30. Explain the ACID properties in database transactions.


1. Atomicity: All or nothing – either all operations succeed or none.
2. Consistency: Database remains in valid state after transaction.
3. Isolation: Concurrent transactions don’t interfere.
4. Durability: Once committed, changes persist despite failure.
These properties ensure reliable, correct, and concurrent transaction processing in a DBMS.

Q31. Write SQL queries for a student database involving SELECT, JOIN, GROUP BY.
Let’s assume two tables:
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

Student(RollNo, Name, DeptID)


Department(DeptID, DeptName)
Marks(RollNo, Subject, Score)
Sample Queries:
1. Simple SELECT with WHERE:

SELECT Name FROM Student WHERE DeptID = 10;


2. JOIN Student with Department:

SELECT [Link], [Link]


FROM Student S
JOIN Department D ON [Link] = [Link];
3. GROUP BY with Aggregation:

SELECT RollNo, AVG(Score) AS AverageScore


FROM Marks
GROUP BY RollNo;
4. JOIN with GROUP BY:
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

SELECT [Link], COUNT([Link]) AS StudentCount


FROM Student S
JOIN Department D ON [Link] = [Link]
GROUP BY [Link];
These queries demonstrate SQL’s capabilities in data retrieval, joins, and aggregation.

Q32. Solve queries using relational algebra for a given schema.


Assume:
● Student(RollNo, Name, Dept)
● Marks(RollNo, Subject, Score)
1. List all students from 'CSE' department:
bash

σ Dept='CSE' (Student)
2. Project student names:

π Name (Student)
3. List students with scores > 70:

σ Score > 70 (Marks)


Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

4. Names of students who scored >70 in 'DBMS':

π Name (σ Subject='DBMS' ∧ Score>70 (Student ⨝ Marks))


Relational algebra uses mathematical operations to express queries and is vital in query
optimization.

Q33. Design a database schema and write SQL3 queries for university application.
Schema:

Student(RollNo, Name, DeptID)


Course(CourseID, Title, Credits)
Enroll(RollNo, CourseID, Grade)
SQL3 Features:
● Use of nested types, user-defined types (UDTs), inheritance

-- UDT for Course


CREATE TYPE CourseType AS OBJECT (
CourseID INT,
Title VARCHAR(100),
Credits INT
);
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

Sample Queries:
1. Insert:

INSERT INTO Student VALUES (101, 'Amit', 'CSE');


2. JOIN Query:

SELECT [Link], [Link], [Link]


FROM Student S
JOIN Enroll E ON [Link] = [Link]
JOIN Course C ON [Link] = [Link];
3. Aggregation:

SELECT CourseID, AVG(Grade) AS AvgGrade


FROM Enroll
GROUP BY CourseID;
SQL3 extends SQL with object-oriented features, useful in complex applications.

Q34. Normalize a given relation to 1NF, 2NF, and 3NF with explanation.
Unnormalized Table:
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

RollNo Name Courses Dept Dept_HOD

101 Ravi DBMS, OS CSE Dr. Kumar

1NF (Atomic values):

Student(RollNo, Name, Course, Dept, Dept_HOD)


| 101 | Ravi | DBMS | CSE | Dr. Kumar |
| 101 | Ravi | OS | CSE | Dr. Kumar |

2NF (Remove partial dependencies):


Separate course from student:

Student(RollNo, Name, Dept)


Department(Dept, Dept_HOD)
Enrollment(RollNo, Course)

3NF (Remove transitive dependencies):


Now all attributes depend only on the key and not on non-prime attributes.
This results in a fully normalized, non-redundant schema ensuring data integrity.
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

Q35. Compare and contrast relational algebra and SQL with examples.
Feature Relational Algebra SQL

Type Procedural Declarative

Use Theoretical foundation Practical query language

Operations select (σ), project (π), join SELECT, JOIN, WHERE

Syntax Mathematical notation English-like syntax

π Name(σ SELECT Name FROM Student WHERE


Example
Dept='CSE'(Student)) Dept='CSE';

Optimization DBMS internal use End-user friendly


Relational algebra is useful for optimization and analysis, while SQL is used in real-world
database management.

Q36. Analyze a case where dependency preservation and lossless join conflict.
Case:
● Relation R(A, B, C) with FDs: A → B, B → C

Decompose into:
● R1(A, B)
● R2(B, C)
● Lossless join: May not be preserved if B is not a key.
● Dependency preservation: B → C preserved in R2
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

But A → B → C is not directly represented in any single relation.

Conclusion:
A decomposition may be lossless but not dependency-preserving, or dependency-preserving
but not lossless.
Ideal decompositions aim to preserve both, but sometimes trade-offs are required.

Q37. Explain join strategies used in query processing and their performance.
1. Nested Loop Join:
o Simple but slow
o Time complexity: O(n*m)
2. Sort-Merge Join:
o Sort both tables, then merge
o Good for sorted data
3. Hash Join:
o Create a hash on smaller relation
o Fast, especially for large joins
4. Index Nested Loop Join:
o Uses index for faster lookup
o Efficient with indexes on join attribute
Performance Tips:
● Choose join strategy based on table size and indexing.
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

● Use hash or merge join for large datasets.

Q38. Describe in detail any two query optimization algorithms with example.
1. Selinger (Cost-Based Optimization):
o Estimates cost for all possible plans
o Uses statistics and histograms
o Chooses lowest-cost plan
2. Rule-Based Optimization:
o Uses heuristics, e.g., push selections before joins
o Does not consider cost
Example:

SELECT * FROM Student WHERE Dept = 'CSE' AND Name = 'Amit';


Optimization:
● Push WHERE clauses near table scan
● Use index on Dept or Name
Modern DBMS use cost-based optimization for better performance.

Q39. Evaluate SQL execution plans and discuss their impact on performance.
SQL Execution Plan:
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

● A roadmap showing how the DBMS will execute a SQL query.


Components:
● Table access methods (Full scan, Index scan)
● Join strategies (Nested loop, Merge)
● Sorting, Filtering, Grouping steps
How to View:

EXPLAIN PLAN FOR SELECT * FROM Student WHERE Dept = 'CSE';


Performance Analysis:
● Full table scan = slower
● Index scan = faster
● Hash joins over nested loops = better for large datasets
Execution plans help developers tune queries for optimal speed.

Q40. Discuss how ACID properties are ensured in multi-user database environments.
1. Atomicity:
o Implemented using transaction logs and rollback mechanisms.
2. Consistency:
o DBMS uses constraints (PK, FK, CHECK) and triggers.
3. Isolation:
Branch: B. Tech CYS Subject: DBMS

Subject Code: BTCS 505-18 Semester: 5th

UNIT 2

o Achieved using locking mechanisms and isolation levels:


▪ Read Uncommitted, Committed, Repeatable Read, Serializable
4. Durability:
o Ensured by writing to log files and stable storage before commit.
In multi-user environments, ACID guarantees that even concurrent or failed transactions do not
compromise data reliability.

You might also like