DBMS Workbook

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Chapter 3 Database Management Systems (DBMS)

3.1 Introduction to DBMS


A Database Management System (DBMS) is a software application that facilitates the creation, management,
and manipulation of databases. It provides an interface for users and applications to interact with the database, ensuring
data integrity, security, and efficiency.
Key Components of DBMS:
Data Definition Language (DDL): DDL is used to define the structure and schema of the database, including
tables, indexes, constraints, and relationships.
Data Manipulation Language (DML): DML is used to retrieve, insert, update, and delete data from the
database. Common DML commands include SELECT, INSERT, UPDATE, and DELETE.
Data Query Language (DQL): DQL is used to query and retrieve data from the database. The most commonly
used DQL command is SELECT, which retrieves data based on specified criteria.
Data Control Language (DCL): DCL is used to control access to the database, including granting and revoking
permissions, and managing user accounts and privileges.
Transaction Management: DBMS ensures the atomicity, consistency, isolation, and durability (ACID prop-
erties) of transactions to maintain data integrity and reliability.
Concurrency Control: DBMS implements concurrency control mechanisms to manage simultaneous access
to the database by multiple users and transactions, preventing data inconsistencies and conflicts.
Backup and Recovery: DBMS provides mechanisms for backing up and restoring data to ensure data avail-
ability and integrity in case of system failures, errors, or disasters.
Types of Database Management Systems:
1. Relational DBMS (RDBMS): RDBMS stores data in tables with rows and columns and uses structured query
language (SQL) for data manipulation and retrieval. Examples include MySQL, Oracle, SQL Server, and Post-
greSQL.
2. NoSQL DBMS: NoSQL databases use non-relational data models and are designed to handle large volumes of
unstructured or semi-structured data. Examples include MongoDB, Cassandra, Couchbase, and Redis.
3. NewSQL DBMS: NewSQL databases combine the scalability and flexibility of NoSQL with the ACID compli-
ance of traditional RDBMS. Examples include Google Spanner, CockroachDB, and NuoDB.
Benefits of Using DBMS:
Data Centralization: DBMS centralizes data storage and management, eliminating data redundancy and in-
consistency.
Data Security: DBMS provides access control mechanisms to protect data from unauthorized access, ensuring
data security and privacy.
Data Integrity: DBMS enforces data integrity constraints, such as unique keys, foreign keys, and check con-
straints, to maintain data consistency and accuracy.
Data Scalability: DBMS supports scalability by allowing the storage and retrieval of large volumes of data
efficiently.
Data Recovery: DBMS provides backup and recovery mechanisms to restore data in case of system failures,
errors, or disasters.
In summary, Database Management Systems (DBMS) play a crucial role in modern information systems, pro-
viding efficient and reliable storage, management, and manipulation of data.
3.2 Relational Database Concepts

3.2 Relational Database Concepts


Relational Database Concepts form the foundation of relational database management systems (RDBMS) and
are essential for understanding how data is organized, stored, and manipulated in relational databases.
Key Concepts of Relational Databases:
Tables: Data in a relational database is organized into tables, which consist of rows and columns. Each row
represents a record or tuple, and each column represents a field or attribute.
Primary Key: A primary key is a unique identifier for each record in a table. It ensures that each row is uniquely
identifiable and provides a way to establish relationships between tables.
Foreign Key: A foreign key is a column or set of columns in one table that references the primary key of another
table. It establishes relationships between tables and ensures referential integrity.
Relationships: Relationships define how tables are connected to each other based on common attributes. Com-
mon types of relationships include one-to-one, one-to-many, and many-to-many.
Normalization: Normalization is the process of organizing data in a database to minimize redundancy and
dependency. It involves dividing large tables into smaller, more manageable tables and defining relationships
between them.
Structured Query Language (SQL): SQL is a standardized language used to interact with relational databases.
It provides commands for creating, querying, updating, and deleting data in tables.
ACID Properties: ACID stands for Atomicity, Consistency, Isolation, and Durability, which are the four prop-
erties that ensure the reliability and consistency of transactions in a relational database.
Advantages of Relational Databases:
Data Integrity: Relational databases enforce data integrity constraints, such as primary key and foreign key
constraints, to maintain data consistency and accuracy.
Flexibility: Relational databases support flexible querying and manipulation of data using SQL, allowing users
to perform complex operations with ease.
Scalability: Relational databases can scale to handle large volumes of data and high transaction loads, making
them suitable for a wide range of applications.
Security: Relational databases provide access control mechanisms to protect data from unauthorized access,
ensuring data security and privacy.
In summary, Relational Database Concepts are fundamental to understanding how relational databases work and
how they are used to organize, store, and manage data effectively.

3.3 SQL (Structured Query Language)


Structured Query Language (SQL) is a standardized language used to interact with relational database man-
agement systems (RDBMS). It provides a set of commands for creating, querying, updating, and deleting data in
databases.
DDL (Data Definition Language):
CREATE TABLE: Creates a new table in the database.
ALTER TABLE: Modifies the structure of an existing table.
DROP TABLE: Deletes a table from the database.
CREATE INDEX: Creates an index on one or more columns of a table.
DROP INDEX: Removes an index from the database.
CREATE DATABASE: Creates a new database.
ALTER DATABASE: Modifies the structure of an existing database.
DROP DATABASE: Deletes a database from the database management system.

137
3.4 Database Design and Normalization

DML (Data Manipulation Language):


SELECT: Retrieves data from one or more tables.
INSERT INTO: Inserts new records into a table.
UPDATE: Updates existing records in a table.
DELETE FROM: Deletes records from a table.
MERGE INTO: Combines insert, update, and delete operations into a single statement.
TRUNCATE TABLE: Removes all records from a table without logging individual row deletions.
COPY: Copies data from a source table to a target table.
FETCH: Retrieves rows from a cursor.
DCL (Data Control Language):
GRANT: Grants permissions to users or roles.
REVOKE: Revokes permissions from users or roles.
These SQL commands are used to define the structure of the database, manipulate data in the database, and control
access to the database.
SQL Syntax:
SELECT Statement:

SELECT column1, column2, ...


FROM table_name
WHERE condition;

INSERT INTO Statement:

INSERT INTO table_name (column1, column2, ...)


VALUES (value1, value2, ...);

UPDATE Statement:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

DELETE FROM Statement:

DELETE FROM table_name


WHERE condition;

These are just a few examples of SQL commands and their syntax. SQL is a powerful language with many more
commands and features for managing relational databases.

3.4 Database Design and Normalization


Database Design is the process of defining the structure and organization of a database to efficiently store, man-
age, and retrieve data. It involves several steps, including identifying the data requirements, designing the database
schema, and optimizing the database for performance and scalability.
Key Components of Database Design:
Entity-Relationship (ER) Modeling: ER modeling is used to identify and define the entities (objects or things)
in the system, their attributes, and the relationships between them. This helps in understanding the data require-
ments and designing the database schema.

138
3.4 Database Design and Normalization

Database Schema: The database schema defines the structure of the database, including the tables, columns,
constraints, and relationships between tables. It provides a blueprint for organizing and storing data in the
database.
Normalization: Normalization is the process of organizing data in a database to minimize redundancy and
dependency. It involves dividing large tables into smaller, more manageable tables and defining relationships
between them to ensure data integrity and optimize performance.
Indexing: Indexing is used to improve the performance of database queries by creating indexes on one or more
columns of a table. Indexes allow for faster data retrieval by enabling the database to quickly locate and access
the required data.
Data Integrity Constraints: Data integrity constraints, such as primary key, foreign key, unique key, and
check constraints, are used to enforce data integrity rules and ensure the accuracy and consistency of data in the
database.
Normalization is a critical aspect of database design that helps in reducing data redundancy, improving data
integrity, and optimizing database performance. It involves several normalization forms, each addressing specific
types of data redundancy and dependency:
1. First Normal Form (1NF): Eliminates repeating groups and ensures that each column contains atomic values.
2. Second Normal Form (2NF): Eliminates partial dependencies by ensuring that each non-key attribute is fully
functionally dependent on the primary key.
3. Third Normal Form (3NF): Eliminates transitive dependencies by ensuring that each non-key attribute is di-
rectly dependent on the primary key.
4. Boyce-Codd Normal Form (BCNF): A stricter form of 3NF that eliminates all non-trivial functional depen-
dencies.
5. Fourth Normal Form (4NF): Addresses multi-valued dependencies by splitting multi-valued attributes into
separate tables.
6. Fifth Normal Form (5NF): Addresses join dependencies by decomposing tables into smaller, independent
tables.
By following the principles of normalization, database designers can create well-structured, efficient databases
that support data integrity, scalability, and performance.

Normalization Example
Consider the following table representing information about students and their courses:

Table 3.1: Student-Course Table


Student_ID Student_Name Course_ID Course_Name
101 Alice C001 Mathematics
102 Bob C002 Physics
103 Charlie C001 Mathematics
104 Alice C003 Chemistry

First Normal Form (1NF): The table is already in 1NF as it contains only atomic values in each cell.
Second Normal Form (2NF): To achieve 2NF, we need to ensure that every non-key attribute is fully functionally
dependent on the primary key. Here, the primary key is Student_ID and Course_ID. Since Student_Name is functionally
dependent on Student_ID and Course_Name is functionally dependent on Course_ID, the table is in 2NF.
Third Normal Form (3NF): In 3NF, we need to eliminate transitive dependencies. Here, Student_Name depends
only on Student_ID, and Course_Name depends only on Course_ID, so the table is in 3NF.
Boyce-Codd Normal Form (BCNF): BCNF is a stricter form of 3NF that eliminates all non-trivial functional
dependencies. Since there are no non-trivial functional dependencies other than the candidate keys, the table is in

139
3.5 Indexing and Query Optimization

BCNF.

3.5 Indexing and Query Optimization


Indexing is a technique used to improve the performance of database queries by creating indexes on one or more
columns of a table. An index is a data structure that stores the values of one or more columns in sorted order, allowing
for faster data retrieval.
Types of Indexes:
Primary Index: Created automatically when a primary key constraint is defined on a column or columns. It
ensures that each row in the table is uniquely identified.
Secondary Index: Created manually to improve the performance of queries that do not use the primary key. It
allows for faster retrieval of data based on non-primary key columns.
Clustered Index: Reorders the physical order of rows in a table based on the values of the indexed column. It
can improve the performance of range queries and ordered scans.
Non-Clustered Index: Stores the indexed column values and pointers to the corresponding rows in the table. It
allows for faster retrieval of data but does not affect the physical order of rows in the table.
Query Optimization is the process of improving the performance of database queries by optimizing their exe-
cution plans. It involves several techniques aimed at reducing the query execution time and resource utilization.
Techniques for Query Optimization:
Index Usage: Utilize indexes to speed up data retrieval operations.
Join Optimization: Optimize join operations by selecting the most efficient join algorithms and join order.
Predicate Pushdown: Push filters and predicates down to the lowest possible level in the query execution plan
to minimize the amount of data processed.
Query Rewriting: Rewrite queries to eliminate redundant operations and optimize query execution.
Parallel Execution: Execute queries in parallel to utilize multiple CPU cores and improve performance.
Caching: Cache frequently accessed data and query results to reduce the need for expensive disk I/O operations.
By utilizing indexing and query optimization techniques, database administrators and developers can significantly
improve the performance and scalability of database systems.

3.6 Transaction Management


Transaction Management is a crucial aspect of database systems that ensures data consistency, integrity, and
reliability. A transaction is a sequence of operations (such as reads and writes) performed on a database that forms
a single logical unit of work. The ACID properties (Atomicity, Consistency, Isolation, Durability) are fundamental
principles of transaction management:
Atomicity: A transaction is atomic, meaning that it either completes successfully and commits all its changes
to the database or fails and leaves the database unchanged. There are no partial or incomplete transactions.
Consistency: Transactions preserve the consistency of the database by ensuring that it transitions from one
consistent state to another consistent state. In other words, transactions maintain data integrity and adhere to all
integrity constraints.
Isolation: Transactions execute in isolation from each other, meaning that the intermediate state of one trans-
action is not visible to other transactions until it is committed. This prevents interference and ensures that
transactions produce consistent results.
Durability: Once a transaction is committed, its changes are permanently saved to the database and are not
lost, even in the event of a system failure. This ensures that committed transactions survive system crashes and
maintain data durability.

140
3.7 NoSQL Databases

Concurrency Control is a key aspect of transaction management that deals with the simultaneous execution of
multiple transactions. Concurrency control techniques ensure that transactions execute correctly and do not interfere
with each other, thereby preserving data consistency and integrity.
Concurrency Control Techniques:
Locking: Lock-based concurrency control mechanisms use locks to prevent conflicting operations from access-
ing the same data simultaneously. Transactions acquire locks on data items before reading or writing them and
release the locks after completing the operation.
Multiversion Concurrency Control (MVCC): MVCC allows multiple versions of data items to exist concur-
rently in the database, enabling transactions to read a consistent snapshot of the database without being blocked
by concurrent write operations.
Timestamp Ordering: Timestamp-based concurrency control assigns a unique timestamp to each transaction
and ensures that transactions execute in a serializable order based on their timestamps. Conflicting transactions
are ordered based on their timestamps to maintain consistency.
Effective transaction management and concurrency control are essential for maintaining the integrity and relia-
bility of database systems in multi-user environments.

3.7 NoSQL Databases


NoSQL (Not Only SQL) databases are a category of databases that provide a non-relational, distributed, and
horizontally scalable approach to data storage and management. Unlike traditional relational databases, which use
structured query language (SQL) and follow the ACID properties (Atomicity, Consistency, Isolation, Durability),
NoSQL databases offer flexible data models, horizontal scalability, and eventual consistency.
Characteristics of NoSQL Databases:
Schema-less Design: NoSQL databases do not require a fixed schema, allowing for dynamic and flexible data
models. This makes it easier to store and manage semi-structured or unstructured data.
Horizontal Scalability: NoSQL databases are designed to scale horizontally across multiple nodes or servers,
enabling them to handle large volumes of data and high read/write throughput.
Distributed Architecture: NoSQL databases are typically distributed systems that replicate data across multiple
nodes for fault tolerance and high availability. They use eventual consistency models to ensure data consistency
over time.
High Performance: NoSQL databases are optimized for high performance and low latency, making them well-
suited for use cases with high data ingestion rates and real-time analytics.
Types of NoSQL Databases:
Document-oriented Databases: Store and retrieve data in the form of documents, such as JSON or BSON
objects. Examples include MongoDB, Couchbase, and Amazon DocumentDB.
Key-value Stores: Store data as key-value pairs, allowing for fast retrieval of data based on unique keys. Ex-
amples include Redis, Amazon DynamoDB, and Riak.
Column-family Stores: Organize data into columns rather than rows, enabling efficient storage and retrieval of
data in wide-column databases. Examples include Apache Cassandra and HBase.
Graph Databases: Model and store data as nodes, edges, and properties, allowing for efficient traversal and
analysis of relationships in interconnected data. Examples include Neo4j, Amazon Neptune, and ArangoDB.
NoSQL databases are widely used in modern web applications, big data analytics, real-time data processing, and
other use cases where flexibility, scalability, and performance are paramount.

141
3.8 Big Data and Distributed Databases

3.8 Big Data and Distributed Databases


Big Data refers to large volumes of structured, semi-structured, and unstructured data that cannot be processed
or analyzed using traditional data processing techniques. Big data is characterized by the three Vs: volume, velocity,
and variety. It includes data from various sources such as social media, sensors, logs, and transaction records.
Characteristics of Big Data:
Volume: Big data involves large volumes of data, ranging from terabytes to petabytes or even exabytes. Tradi-
tional databases may struggle to handle such massive amounts of data efficiently.
Velocity: Big data is generated at high velocity, often in real-time or near real-time. Streaming data from sources
such as social media feeds, IoT devices, and clickstream data requires fast processing and analysis.
Variety: Big data comes in various forms, including structured, semi-structured, and unstructured data. It
includes text, images, videos, sensor data, logs, and more. Traditional databases may not be equipped to handle
such diverse data types.
Distributed Databases are databases that are spread across multiple nodes or servers in a distributed comput-
ing environment. Distributed databases are designed to handle large volumes of data and high transaction loads by
distributing data processing and storage tasks across multiple nodes.
Characteristics of Distributed Databases:
Scalability: Distributed databases are highly scalable, allowing organizations to scale their databases horizon-
tally by adding more nodes or servers to accommodate growing data volumes and user loads.
Fault Tolerance: Distributed databases are fault-tolerant, meaning they can continue to operate even if in-
dividual nodes or components fail. They replicate data across multiple nodes to ensure data availability and
reliability.
Consistency: Distributed databases ensure data consistency by implementing mechanisms such as distributed
transactions, consensus algorithms, and conflict resolution protocols to maintain a consistent view of data across
all nodes.
Performance: Distributed databases are designed for high performance, enabling fast data retrieval and pro-
cessing across distributed environments. They leverage parallel processing and distributed query execution to
optimize performance.
Distributed databases are widely used in big data analytics, cloud computing, distributed systems, and other
applications where scalability, fault tolerance, and performance are critical.

3.9 Current Trends in DBMS


Database Management Systems (DBMS) continue to evolve to meet the changing needs and challenges of
modern applications and environments. Several current trends are shaping the development and adoption of DBMS
technologies:
Cloud-based Databases: There is a growing trend towards cloud-based database solutions, where databases are
hosted and managed in the cloud. Cloud databases offer scalability, flexibility, and cost-effectiveness, enabling
organizations to easily scale their databases and pay only for the resources they consume.
Big Data Analytics: With the proliferation of big data, there is an increasing demand for DBMS technologies
that can handle large volumes of data and support advanced analytics and machine learning algorithms. NoSQL
databases, distributed databases, and in-memory databases are commonly used for big data analytics.
Real-time Data Processing: Real-time data processing has become essential for many applications, such as
online transaction processing (OLTP), real-time analytics, and IoT data processing. DBMS technologies that
support real-time data ingestion, stream processing, and event-driven architectures are in high demand.
Microservices Architecture: Microservices architecture, where applications are composed of loosely coupled

142
3.10 Frequently Asked Interview Questions

and independently deployable services, is gaining popularity. DBMS technologies that support microservices
architectures, such as containerization, orchestration, and service discovery, are becoming increasingly impor-
tant.
Graph Databases: Graph databases are gaining traction for applications that require efficient storage and query-
ing of graph-structured data, such as social networks, recommendation systems, and network analysis. Graph
databases offer powerful graph algorithms, traversal capabilities, and schema flexibility.
Blockchain Databases: Blockchain technology is being used to implement decentralized and tamper-resistant
databases for applications such as cryptocurrency, supply chain management, and digital identity verification.
Blockchain databases provide immutability, transparency, and cryptographic security.
These trends are driving innovation in the field of DBMS and shaping the future of data management and analytics.

3.10 Frequently Asked Interview Questions


1. What is an Entity-Relationship (ER) diagram, and what is its purpose?
2. Describe the main components of an ER diagram.
3. What is an entity, and how is it represented in an ER diagram?
4. Explain the different types of entities commonly used in ER diagrams.
5. What is an attribute, and how is it represented in an ER diagram?
6. Describe the different types of attributes, including simple, composite, and derived attributes.
7. What is a relationship, and how is it represented in an ER diagram?
8. Explain the cardinality and participation constraints in relationships.
9. Describe the different types of relationships, including one-to-one, one-to-many, and many-to-many relation-
ships.
10. What are weak entities, and how are they represented in an ER diagram?
11. Explain the concept of identifying and non-identifying relationships.
12. What is an associative entity, and when is it used in an ER diagram?
13. How do you denote specialization and generalization in an ER diagram?
14. What are the key differences between an ER diagram and a relational schema?
15. Describe the process of converting an ER diagram into a relational schema.
16. How do you validate the correctness of an ER diagram?
17. What are some best practices for designing effective ER diagrams?
18. Explain the concept of aggregation in ER diagrams.
19. How can you represent constraints and business rules in an ER diagram?
20. What are some common tools used for creating and manipulating ER diagrams?
21. What is a Database Management System (DBMS), and what are its main functions?
22. Describe the key components of a DBMS architecture.
23. What are the advantages of using a DBMS over traditional file-based systems?
24. Explain the concept of data independence in the context of DBMS.
25. Describe the role of the Data Definition Language (DDL) in a DBMS.
26. What is a data model, and how does it relate to a DBMS?
27. Discuss the difference between a relational database and a NoSQL database.
28. How does a DBMS ensure data integrity and security?
29. Explain the concept of transaction management in a DBMS.
30. What are the common types of users in a DBMS environment?
31. What is a relational database management system (RDBMS), and how does it differ from other types of DBMS?
32. Describe the characteristics and advantages of a hierarchical database management system.

143
3.10 Frequently Asked Interview Questions

33. Explain the concept of network database management systems (NDBMS).


34. What is an object-oriented database management system (OODBMS), and when is it used?
35. Discuss the characteristics and use cases of a document-oriented database management system.
36. Explain the concept of a columnar database management system (CDBMS).
37. What is a graph database management system (GDBMS), and how does it represent data?
38. Describe the characteristics and advantages of an in-memory database management system.
39. What is a time-series database management system, and what types of data does it handle?
40. Discuss the role of distributed database management systems (DDBMS) in modern computing environments.
41. What is a primary key, and why is it important in a relational database?
42. Describe the characteristics of a primary key.
43. How is a primary key different from other types of keys in a database?
44. Can a primary key contain null values? Why or why not?
45. Explain the concept of surrogate keys and their role in primary key design.
46. What are the advantages of using a natural key as opposed to a surrogate key?
47. Discuss the process of selecting a suitable primary key for a table.
48. How does a primary key enforce entity integrity in a relational database?
49. What happens if you try to insert a duplicate value into a primary key column?
50. Can a table have multiple primary keys? Explain.
51. What is a foreign key, and how is it used in a relational database?
52. Describe the relationship between a foreign key and a primary key in a database.
53. How does a foreign key enforce referential integrity between related tables?
54. Can a foreign key contain null values? When is this allowed?
55. Explain the difference between a foreign key constraint and a foreign key index.
56. Discuss the process of creating a foreign key constraint in a table.
57. What happens if you try to insert a value into a foreign key column that does not exist in the referenced table?
58. Can a table have multiple foreign keys? Are there any limitations to this?
59. How do you handle cascading updates and deletes with foreign key constraints?
60. What are the benefits of using foreign keys in database design?
61. What is normalization and why is it important in database design?
62. Explain the purpose of normal forms in the context of database normalization.
63. Can you describe the process of normalization and its stages?
64. What are the different normal forms, and what are their characteristics?
65. How does normalization help in reducing redundancy and improving data integrity?
66. Discuss the advantages and disadvantages of normalization.
67. Explain the concept of functional dependencies and how they relate to normalization.
68. What is the difference between partial dependency and transitive dependency? How do they impact normaliza-
tion?
69. Can you provide examples of violations of different normal forms and how they can be resolved through nor-
malization?
70. How do you determine which normal form a database table is currently in?
71. In what scenarios would denormalization be appropriate, and what are the trade-offs compared to normalization?
72. Discuss the role of candidate keys and primary keys in normalization.
73. How does normalization affect query performance and database maintenance?
74. Explain the process of database normalization in the context of a real-world example or case study.
75. How does normalization contribute to better scalability and flexibility in database systems?
76. What is SQL and what does it stand for?

144
3.10 Frequently Asked Interview Questions

77. Name different categories of SQL commands.


78. What is a database table?
79. What is a DBMS and how does it differ from an RDBMS?
80. What are the different types of keys in SQL?
81. Explain the difference between DELETE and TRUNCATE commands.
82. What is a NULL value in SQL?
83. How do you comment in SQL?
84. What is a subquery and how is it different from a regular query?
85. Explain the difference between UNION and UNION ALL.
86. How do you use the DISTINCT keyword in SQL?
87. What are the basic DML commands in SQL?
88. How do you insert data into a table in SQL?
89. Explain the difference between the WHERE and HAVING clauses.
90. How do you update existing data in a table in SQL?
91. What is the difference between the INSERT and INSERT INTO commands?
92. How do you delete records from a table in SQL?
93. Explain the difference between TRUNCATE and DELETE commands.
94. What are the basic DDL commands in SQL?
95. How do you create a table in SQL?
96. Explain the difference between CHAR and VARCHAR data types.
97. How do you add a new column to an existing table in SQL?
98. What is a constraint in SQL and why is it used?
99. How do you drop a table in SQL?
100. Explain the difference between the DROP and TRUNCATE commands.
101. How do you define primary and foreign keys in SQL?
102. What is a SQL query?
103. How do you write a SELECT statement in SQL?
104. Explain the difference between the WHERE and HAVING clauses in SQL.
105. What is the ORDER BY clause used for in SQL?
106. How do you limit the number of records returned in a SQL query?
107. Explain the LIKE operator in SQL.
108. How do you perform a join operation in SQL?
109. What are the different types of joins in SQL?
110. Explain the difference between INNER JOIN and OUTER JOIN.
111. How do you use the GROUP BY clause in SQL?
112. What is the purpose of the DISTINCT keyword in SQL?
113. What are SQL functions and why are they used?
114. Explain the difference between aggregate functions and scalar functions.
115. What is the purpose of the COUNT() function in SQL?
116. How do you use the MAX() and MIN() functions in SQL?
117. What is the purpose of the SUM() and AVG() functions in SQL?
118. Explain the difference between the DISTINCT and ALL keywords in SQL.
119. What is normalization and why is it important in SQL?
120. Explain the different normal forms in SQL.
121. What is denormalization and when would you use it?
122. How do you create views in SQL?

145
3.10 Frequently Asked Interview Questions

123. What are stored procedures and how do you create them in SQL?
124. What is indexing in SQL and why is it important?
125. How do you optimize SQL queries for performance?
126. Explain the difference between relational algebra and SQL.
127. What are the fundamental operations in relational algebra?
128. How do you represent relations in relational algebra?
129. Describe the basic syntax of relational algebra expressions.
130. What is a relational schema, and how is it used in relational algebra?
131. Explain the SELECT operation in relational algebra.
132. How does the PROJECT operation work in relational algebra?
133. Describe the difference between the JOIN and CROSS JOIN operations.
134. What is the difference between UNION and INTERSECTION in relational algebra?
135. Explain the purpose of the RENAME operation in relational algebra.
136. How do you perform set difference in relational algebra?
137. What is the DIVISION operation in relational algebra, and when is it used?
138. Describe the SEMIJOIN operation and its significance in relational algebra.
139. What is the NATURAL JOIN operation, and how does it differ from other types of joins?
140. Explain the purpose of the OUTER JOIN operation in relational algebra.
141. How do you perform aggregation operations in relational algebra?
142. Describe how recursive queries can be represented in relational algebra.
143. How can you optimize relational algebra expressions for better performance?
144. Explain the concept of query optimization in relational algebra.
145. What are some common optimization techniques used in relational algebra?
146. How does indexing impact query performance in relational algebra?
147. Describe the concept of query execution plans in relational algebra.
148. Discuss the role of relational algebra in relational database theory.
149. How does relational algebra facilitate database query processing?
150. Explain how relational algebra operations are used in practice for database manipulation.
151. Describe the relationship between relational algebra and database normalization.
152. How does relational algebra relate to the relational model of data?
153. How do you write a relational algebra expression to find the Cartesian product of two relations?
154. Explain how you would retrieve data from multiple tables using relational algebra.
155. How do you perform nested queries in relational algebra?
156. Describe the process of composing complex relational algebra expressions.
157. Provide an example of a complex query expressed in relational algebra.
158. Can you provide examples of real-world scenarios where relational algebra is used?
159. How does relational algebra support data manipulation in database management systems?
160. Describe how relational algebra expressions are translated into SQL queries in practice.
161. What are some challenges associated with using relational algebra in database systems?
162. Discuss the limitations of relational algebra in representing complex queries.
163. How do you address scalability issues when working with relational algebra expressions?
164. Explain the trade-offs involved in using relational algebra for database query processing.
165. What is a functional dependency (FD) in the context of relational databases?
166. How do you define a functional dependency between attributes in a relation?
167. Explain the difference between a candidate key and a superkey in terms of functional dependencies.
168. What is closure of attributes in functional dependencies, and why is it important?

146
3.10 Frequently Asked Interview Questions

169. How do you represent functional dependencies using notation?


170. What are the steps involved in determining functional dependencies in a relation?
171. Explain Armstrong’s Axioms and how they are used to derive functional dependencies.
172. Describe how you can use attribute closure to determine functional dependencies.
173. Can you provide an example of identifying functional dependencies in a given relation?
174. How are functional dependencies related to the normalization process in database design?
175. Explain the concept of partial dependency and how it relates to functional dependencies.
176. What is transitive dependency, and why is it important in normalization?
177. How do you use functional dependencies to decompose relations into higher normal forms?
178. Provide an example of how normalization based on functional dependencies can eliminate redundancy.
179. What is the role of keys in determining functional dependencies?
180. How do you identify candidate keys using functional dependencies?
181. Can a relation have multiple candidate keys, and if so, how are they related to functional dependencies?
182. Explain how primary keys and foreign keys are determined based on functional dependencies.
183. What is the closure of a set of attributes in functional dependencies?
184. How do you calculate the closure of attributes using Armstrong’s axioms?
185. Explain the concept of a canonical cover and its significance in functional dependency analysis.
186. How do you find the canonical cover of a set of functional dependencies?
187. What are multivalued dependencies, and how do they differ from functional dependencies?
188. Can you provide an example of a relation that exhibits multivalued dependencies?
189. Describe the concept of join dependencies and their relationship to functional dependencies.
190. How do you ensure data integrity when dealing with complex dependencies in a database?
191. Can you provide examples of real-world scenarios where understanding functional dependencies is important?
192. How do functional dependencies impact database design and query optimization?
193. Describe how database systems utilize functional dependencies for data manipulation and storage.
194. What are some challenges associated with determining functional dependencies in large, complex databases?
195. Discuss the limitations of using functional dependencies as the sole basis for database normalization.
196. How do you handle anomalies that may arise due to incorrect or incomplete functional dependency analysis?
197. What is a transaction in the context of a database management system (DBMS)?
198. Explain the ACID properties of transactions and their significance.
199. How does a DBMS ensure atomicity, consistency, isolation, and durability in transactions?
200. Describe the difference between a serial and concurrent transaction execution.
201. What is a transaction log, and how is it used in DBMS?
202. Explain the purpose of transaction management in a DBMS.
203. What are the different states that a transaction can be in during its execution?
204. How does a DBMS ensure that transactions are executed reliably and efficiently?
205. Describe the role of locks and latches in transaction management.
206. What is a deadlock, and how does a DBMS handle deadlock situations?
207. How do you handle transaction rollback and commit operations?
208. What is concurrency control, and why is it important in transaction management?
209. Explain the difference between pessimistic and optimistic concurrency control.
210. How do you implement locking mechanisms for concurrency control in a DBMS?
211. Describe the concept of two-phase locking (2PL) and its role in concurrency control.
212. What is a transaction isolation level, and how does it affect concurrency?
213. Explain the different isolation levels supported by most DBMSs (e.g., READ UNCOMMITTED, READ COM-
MITTED, REPEATABLE READ, SERIALIZABLE).

147
3.10 Frequently Asked Interview Questions

214. What are the trade-offs between different isolation levels in terms of consistency and concurrency?
215. How does a DBMS ensure the isolation property for each isolation level?
216. Can you provide examples of scenarios where different isolation levels would be appropriate?
217. Describe the process of transaction recovery in a DBMS.
218. What is a checkpoint, and how does it help in transaction recovery?
219. Explain the role of the transaction log in recovery operations.
220. How does a DBMS handle system crashes during transaction execution?
221. Can you explain the difference between forward and backward recovery techniques?
222. What are distributed transactions, and how do they differ from local transactions?
223. Describe the challenges associated with managing distributed transactions.
224. How do you ensure atomicity and consistency in distributed transactions?
225. Explain the role of distributed locks in ensuring data integrity across multiple sites.
226. What is a two-phase commit protocol, and how does it work in distributed transactions?
227. How can you optimize transaction processing for better performance?
228. Describe the concept of transaction batching and its impact on performance.
229. What are the factors that affect transaction throughput and response time?
230. Explain the role of indexing and caching in improving transaction performance.
231. How do you measure and monitor transaction performance in a DBMS?
232. Can you provide examples of real-world scenarios where transaction management is crucial?
233. How do e-commerce platforms utilize transactions to ensure data consistency and integrity?
234. Describe how banking systems handle transactions to maintain accurate account balances.
235. What are some challenges unique to handling transactions in large-scale distributed systems?
236. How do social media platforms ensure data consistency and isolation in transactional operations?
237. What is an unstructured database, and how does it differ from structured databases?
238. Can you provide examples of unstructured data formats commonly stored in unstructured databases?
239. Explain the challenges associated with managing and querying unstructured data compared to structured data.
240. How do unstructured databases handle schema flexibility and schema evolution?
241. Describe the storage mechanism used in unstructured databases.
242. How do you efficiently retrieve and query unstructured data from an unstructured database?
243. Explain the role of indexing in unstructured databases and its impact on retrieval performance.
244. Can you discuss the trade-offs between different storage and retrieval techniques for unstructured data?
245. What are some common methods for querying unstructured databases?
246. Explain the concept of full-text search and how it is implemented in unstructured databases.
247. How do you perform advanced analytics and data mining on unstructured data?
248. Describe the challenges associated with performing complex queries on unstructured data compared to structured
data.
249. How do unstructured databases scale horizontally to handle large volumes of data?
250. What are some strategies for optimizing performance in unstructured databases?
251. Explain how distributed computing techniques are used to improve scalability and performance in unstructured
databases.
252. Can you discuss the role of caching and replication in enhancing performance in unstructured databases?
253. How do you integrate unstructured data from different sources into an unstructured database?
254. Describe the process of transforming unstructured data into a structured format for analysis.
255. What are some challenges associated with integrating and transforming unstructured data?
256. How do you ensure data security and privacy in unstructured databases?
257. What are some common security vulnerabilities associated with unstructured databases?

148
3.10 Frequently Asked Interview Questions

258. Explain the role of access control mechanisms in protecting unstructured data.
259. How do unstructured databases handle schema evolution and versioning?
260. Can you discuss the challenges of maintaining backward compatibility when evolving the schema of unstructured
data?
261. What strategies can be used to manage schema changes in unstructured databases while minimizing disruption?
262. Can you provide examples of industries or use cases where unstructured databases are commonly used?
263. How do content management systems leverage unstructured databases to store and manage documents, images,
and multimedia content?
264. Explain how social media platforms utilize unstructured databases to store and analyze user-generated content.
265. What are some challenges specific to healthcare or scientific research that can be addressed using unstructured
databases?
266. Can you discuss the role of unstructured databases in supporting natural language processing and sentiment
analysis applications?
267. What are some emerging technologies or trends that are shaping the future of unstructured databases?
268. How do advancements in machine learning and artificial intelligence impact the capabilities of unstructured
databases?
269. Can you discuss the potential impact of blockchain technology on the evolution of unstructured databases?
270. What are some key areas of research or development in unstructured databases that you find promising?

149
3.11 Worksheets

3.11 Worksheets
Worksheet 1

Multiple Choice Questions


1. What is an example of RDBMS?
A. SQL
B. MS SQL Server
C. IBM DB2
D. All of the above
2. What is TRUE about RDBMS?
A. Representation of data is done in form of Column.
B. Every table contains its own candidate key.
C. There is a collection of organized set of tables.
D. It is uncommonly used database.
3. A small entity that contains the specific information of each record in the table is known as ...........
A. Row
B. Column
C. Field
D. Record
4. An operation is part of a transaction if it is .......... related.
A. Logically
B. Analytically
C. Reasonably
D. None
5. What is the purpose of the UNION operator in SQL?
A. It combines the results of two or more SELECT statements.
B. It performs a pattern match on a string.
C. It retrieves the maximum value in a column.
D. It filters the rows returned by the SELECT statement.
6. Which SQL command is used to update existing data in a database table?
A. MODIFY
7. By normalizing relations or sets of relations, one minimizes .
A. Data
B. Fields
C. Redundancy
D. Database
8. In addition to removing undesirable characteristics, normalization also eliminates a nomalies.
A. Insert
B. Update
C. Delete
D. All of the above
9. To access the contents of the database, u serperf ormstransactions.
A. Single
B. Two

150
3.11 Worksheets

C. Three
D. Multiple
10. A common approach to normalization is to t helargertableintosmallertablesandlinkthemtogetherbyusingrelationships.
A. Add
B. Subtract
C. Multiply
D. Divide

Subjective Questions
1. Define SQL?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. List out the Numeric Data and character Data Types in MySQL?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. List out the commands under DML and their syntax.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

151
3.11 Worksheets

....................................................................................................
....................................................................................................
....................................................................................................
4. Based on the given table “SALE” answer the question (i) and (ii)

PRODID QTY RATE AMOUNT


1 10 100 1000
2 5 50 250
3 10 20 200
4 20 100 2000

(i) Can we take QTY column of the above table as Primary Key? If no give reason?
(ii) Which column is best suitable for applying Primary Key?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. What is referential Integrity? How it is implemented in any table?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Table T1 contains 10 Rows and 4 Columns; Table T2 contains 20 Rows and 3 Columns. After performing
Cartesian product of T1 and T2, what will be the degree and cardinality of Resultant output?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

152
3.11 Worksheets

....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

153
3.11 Worksheets

Worksheet 2

Multiple Choice Questions


1: What For each attribute of a relation, there is a set of permitted values, called the of that attribute.
A. Dictionaries
B. Domain
C. Directory
D. Relation
2: What does NULL value specify in RDBMS?
A. The field is set to Zero
B. The field is set to Infinite
C. The field is left blank
D. The field is set to Whole Number
3: RDBMS applications stores data .
A. In tabular form
B. As file
C. Both a and b
D. None of the above
4: What is the purpose of the WHERE clause in SQL?
A. It specifies the columns to be retrieved.
B. It filters the rows returned by the SELECT statement.
C. It orders the results in ascending or descending order.
D. It creates a new table.
5: In what format data is stored in DBMS?
A. Hierarchal form
B. Navigational form
C. Both A. and B.
D. None of the above
6: Redundancy is reduced in a database table by using the f orm.
A. Abnormal
B. Normal
C. Special
D. None
7: X is read from a database and stored in a buffer in main memory with the o peration.
A. Read
B. Write
C. Commit
D. Rollback
8: In practical applications, how many types of Normal Forms are there?
A. 3
B. 4
C. 5
D. 6
9: In DBMS –
A. There is no relation between the tables

154
3.11 Worksheets

B. There is relation between the tables


C. There is custom relation between the databases
D. There is data value relation between the databases
10: Which of the following is not a type of Normal Form?
A. 1NF
B. 2NF
C. 3NF
D. 10NF

Subjective Questions
1. Write any 2 characteristics of a Relation.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. What is alternate Key?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. From the following Tables: Table 3.2 (EMP) AND Table 3.3 (JOB) answer the questions

Table 3.2: Employee Table


EMPNO ENAME JOB SALARY DEPTNO
E001 PETER ADMIN 4500 10
E002 SCOTT SALESMAN 3500 20
E003 ALBERT CLERK 2800 10
E004 RUSSEL CLERK 2900 40

(a). Identify Primary Key from both the tables

155
3.11 Worksheets

Table 3.3: Job Table


DEPTNO DNAME DLOCATION DHEAD
10 PETER ADMIN 4500
20 SCOTT SALESMAN 3500
30 ALBERT CLERK 2800
40 RUSSEL CLERK 2900

(b). Identify the foreign key column in the table EMP


(c). Can we delete the record of PETER from table JOB?
(d). If not, give a reason
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
Table 3.4: Visitor Table
VisitorID VisitorName ContactNumber
V001 ANAND 9898989898
V002 AMIT 9797979797
V003 SHYAM 9696969696
V004 MOHAN 9595959595

4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Mr. Peter created a table in MySQL. later on, he found that there should have been another column in the table.
Which command should he use to add another column to the table.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

156
3.11 Worksheets

....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Give 1 example for aggregate functions (count, max, min, sum).
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

157
3.11 Worksheets

Worksheet 3

Multiple Choice Questions


1: What is the purpose of the GROUP BY clause in SQL?
A. It filters the rows returned by the SELECT statement.
B. It groups rows with the same values into summary rows.
C. It orders the results in ascending or descending order.
D. It specifies the columns to be retrieved.
2: ......... is used to permanently save the work.
A. Read
B. Write
C. Commit
D. Rollback
3: Distributed database is supported by -
A. RDBMS
B. DBMS
C. Both RDBMS DBMS
D. Neither RDBMS nor DBMS
4: RDBMS supports .......... users.
A. One
B. Two
C. None
D. Multiple
5: An undo operation is called a .........
A. Rollback
B. Commit
C. Write
D. Read
6: What is the purpose of the DISTINCT keyword in SQL?
A. It filters the rows returned by the SELECT statement.
B. It specifies the columns to be retrieved.
C. It removes duplicate rows from the result set.
D. It orders the results in ascending or descending order.
7: How many properties of transactions are there?
A. 4
B. 5
C. 6
D. 7
8: DBMS deals with ....... amount of data.
A. Large
B. Small
C. Custom
D. None
9: What is the purpose of the UNION operator in SQL?
A. It combines the results of two or more SELECT statements.

158
3.11 Worksheets

B. It performs a pattern match on a string.


C. It retrieves the maximum value in a column.
D. It filters the rows returned by the SELECT statement.
10: “Address” field of a table cannot be a part of Primary key as it is likely to:
A. Dependent
B. Changed
C. Too Long
D. Not Changed

Subjective Questions
1. Observe the following table and answer the questions TABLE 3.5 VISITOR and answer the question (i) , (ii)
and (iii)

Table 3.5: Visitor Table


VisitorID VisitorName ContactNumber
V001 ANAND 9898989898
V002 AMIT 9797979797
V003 SHYAM 9696969696
V004 MOHAN 9595959595

(i) Write the name of most appropriate columns which can be considered as Candidate keys
(ii) Out of selected candidate keys, which one will be the best to choose as Primary Key?
(iii) What is the degree and cardinality of the table
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. What is the difference between Primary Key and Candidate Key?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

159
3.11 Worksheets

....................................................................................................
....................................................................................................
....................................................................................................
3. What are the differences between DELETE and DROP commands of SQL?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Write the SQL query to display price of products without duplicate values.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Write the SQL query to drop the table employee.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Write the SQL query to count the number of product with product code is PEN.
....................................................................................................
....................................................................................................
....................................................................................................

160
3.11 Worksheets

....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

161
3.11 Worksheets

Worksheet 4

Multiple Choice Questions


1: There needs to be which of the following conditions for each nontrivial dependency of function X on function
Y for a relation to be in third normal form.
A. A super key is X.
B. Every element of Y is a part of some candidate key, i.e, Y is a prime attribute.
C. Either A or B
D. None of the above
2: What is TRUE about the First Normal Form (1NF)?
A. If a relation contains an atomic value, it will be 1NF.
B. A table attribute cannot contain more than one value, according to this rule.
C. A single-valued attribute can only be stored in it.
D. All of the above
3: What is TRUE about Isolation?
A. By using the data used during a transaction, the second transaction will not be able to use it until the first
has been executed.
B. The data item X cannot be accessed by any other transaction T2 until the transaction T1 is completed and
the data item X is used by the transaction T1.
C. It enforced the isolation property via its concurrency control subsystem.
D. All of the above
4: 2NF relations are those that are in 1NF with all the attribute types dependent on the ...... key.
A. Primary
B. Foreign
C. Composite
D. Alternate
5: When a relation contains an atomic value, it is a ...... relation.
A. 1NF
B. 2NF
C. 3NF
D. BCNF
6: Transactions that are ...... do not expose all changes.
A. Committed
B. Rollbacked
C. Aborted
D. None of the above
7: What is TRUE about atomicity?
A. The transaction cannot be partially completed, since there is no midway.
B. In each transaction, either the entire transaction is executed or it is not.
C. Both A and B
D. None of the above
8: ....... states that all operations of a transaction must occur simultaneously; otherwise, the transaction will be
aborted.
A. Atomicity
B. Consistency

162
3.11 Worksheets

C. Isolation
D. Durability
9: In a database, prior to and after a transaction, properties are used to ensure .......
A. Consistency
B. Redundancy
C. Latency
D. Anonymity
10: Column names of any table must be:
A. Must be numeric type
B. Must be unique
C. Must be in sorted order
D. Must not be greater than 40 characters

Subjective Questions
1. Write the SQL query to update product code to PEC for product ID 1002.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Write short notes on following relational terms:
a. Tuple
b. Attribute
c. Relation
d. Domain
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Write the SQL query to display the maximum, minimum, average of price and total quantity of all products.

163
3.11 Worksheets

....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Differentiate between DBMS and RDBMS. Discuss its different functions.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Observe the following Table 3.6 TEACHER and Table 3.7 TASK carefully and write the names of the RDBMS
operation out of (i) EQUI JOIN(ii) NATURAL JOIN(iii) SELECTION (iv)CARTESIAN PRODUCT, which
has been used to product the output as shown below. Also find the Degree and Cardinality of final RESULT.

Table 3.6: Teacher Information


Teacher_Code Teacher_Name Subject
T001 Amit Biology
T002 Anand Hindi
T003 Mohan Physics

Table 3.7: Task


Teacher Name Subject Task Name Completion Date
Amit Biology SBSB 30-04-2020
Amit Biology EBSB 31-05-2020
Amit Biology GANGA_QUEST 30-04-2020
Anand Hindi SBSB 30-04-2020
Anand Hindi EBSB 31-05-2020
Anand Hindi GANGA_QUEST 30-04-2020
Mohan Physics SBSB 30-04-2020
Mohan Physics EBSB 31-05-2020
Mohan Physics GANGA_QUEST 30-04-2020

164
3.11 Worksheets

....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Write the SQL queries:
(a). Retrieve all tasks along with the respective teacher information.
(b). Find out the completion date and subject for each task.
(c). Get the teacher name, subject, and task name for tasks completed on 31-05-2020.
(d). List all tasks along with the teacher’s subject and the completion date.
(e). Find out the tasks completed by each teacher with their respective subjects.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

165

You might also like