DBMS QB (Solved)
DBMS QB (Solved)
DBMS QB (Solved)
UNIT – 1, 2 SAQs
6. Write the difference between SQL & NoSQL with examples. ***
SQL NOSQL
It has relational data model. Data is It has a distributed database
stored in rows and columns in the system. Data is stored in the form of
form of tables. key-value, etc.
It has a rigid schema with It has flexible schema.
predefined structure.
1
CSD – 2B
2
CSD – 2B
Using the DDL statements, you can create the skeleton of the
database. Data definition language is used to store the information of
metadata like the number of tables and schemas, their names,
indexes, columns in each table, constraints, etc.
Here are some tasks that come under DDL:
1. Create: It is used to create objects in the database.
2. Alter: It is used to alter the structure of the database.
3. Drop: It is used to delete objects from the database.
4. Truncate: It is used to remove all records from a table.
5. Rename: It is used to rename an object.
6. Comment: It is used to comment on the data dictionary
3
CSD – 2B
3. End Users: End users are those individuals whose occupations need
them to have access to the database for the purposes of querying,
updating, and producing reports.
Categories of End Users are:
Casual End User: They may occasionally visit the database, but
each time they might require a different set of data. They are often
supervisors at the medium or high levels or other infrequent
browsers.
Naive End User: Their primary duty is to continuously update and
query the database using tried-and-true, precisely coded and tested
queries and updates. Naive end users include people working as
bank tellers, hotel and airline reservation clerks, etc.
Sophisticated End User: Engineers, scientists, business analysts,
and other sophisticated end users are examples of sophisticated
end users who extensively educate themselves with the DBMS's
4
CSD – 2B
5
CSD – 2B
7
CSD – 2B
9
CSD – 2B
UNIT – 2 LAQs
1. Define the various set operational of relational algebra?
Relational Algebra is a Procedural language. It means how to obtain the
result. In Relational Algebra, the order is specified in which the operations
have to be performed It is independent of the domain and is nearer to a
programming language.
The set operation is mainly categorized into the following:
1. Union operation:
The union operation combines the rows of two relations into a
single relation, removing duplicate rows.
It is denoted by the symbol ∪.
2. Intersection operation:
The intersection operation selects only the rows that appear in
both relations.
It is denoted by the symbol ∩
3. Minus operation:
The difference operation selects the rows from one relation that
do not appear in another relation.
It is denoted by the symbol -
4. Cartesian Product:
The Cartesian product operation combines every row of one
relation with every row of another relation, resulting in a new
relation with all possible combinations of rows.
It is denoted by the symbol ×.
10
CSD – 2B
algebra, offers simplicity and ease of use, enabling users to express queries
in a more intuitive and abstract manner without worrying about the underlying
implementation details.
UNIT – 3 SAQs
1. What are DDL and DML commands with syntax and examples?
DDL (Data Definition Language) commands define, modify, or remove
Ans: database structure. The commands of DDL with syntaxes are as follows:
Create table: Create table table_name (column1 datatype, column2
datatype);
Alter: Alter table table_name add column column_name datatype;
Drop: Drop table table_name;
13
CSD – 2B
2. Write about DCL and TCL commands with syntax and examples
DCL (Data Control Language) is used to retrieve saved data. The commands
of DCL with syntaxes are as follows:
Grant: Grant select, insert on table_name to user1.
Revoke: Revoke insert on table_name from user1;
TCL (Transactional Control Language) is used to run changes made by DML
commands.The commands of TCL with syntaxes are as follows:
Commit: Commit;
Rollback: Rollback;
15
CSD – 2B
UNIT – 3 LAQs
2. Key-Value Stores:
A key-value store is a nonrelational database.
The simplest form of a NoSQL database is a key-value store.
Every data element in the database is stored in key-value pairs.
The data can be retrieved by using a unique key allotted to each
element in the database.
The values can be simple data types like strings and numbers or
complex objects.
Key features of the key-value are Simplicity, Scalability, Speed.
16
CSD – 2B
4. Graph-Based databases:
Graph-based databases focus on the relationship between the
elements.
It stores the data in the form of nodes in the database.
The connections between the nodes are called links or
relationships.
It is easy to identify the relationship between the data by using
the links.
The Query’s output is real-time results.
The speed depends upon the number of relationships among the
database elements.
Updating data is also easy, as adding a new node or edge to a
graph database is a straightforward task that does not require
significant schema changes.
2. Write the difference between SQL & NoSQL with examples. ***
SQL NOSQL
It has relational data model. Data is It has a distributed database
stored in rows and columns in the system. Data is stored in the form of
form of tables. key-value, etc.
It has a rigid schema with It has flexible schema.
predefined structure.
SQL language is used. Various other languages are used
depending on the database.
Vertically scalable Horizontally scalable.
Best suited for complex queries. Not so good for complex queries.
Follows ACID properties. Follows CAP (Consistency,
Availability, Partition tolerance)
Example: MySQL, oracle, etc. Example: MongoDB, HBase
17
CSD – 2B
18
CSD – 2B
19
CSD – 2B
20
CSD – 2B
21
CSD – 2B
UNIT – 4 SAQs
1. What is transaction?
A database transaction is a set of related database operations such as
insertions, updates, or deletions that are treated as a single unit. It ensures
that all operations are either completed successfully or reverted entirely in
case of failure.
OR
Transactions are a set of operations used to program a logical set of work.
2. What are the various states of transactions?
The common states include: Active state, Partially committed state,
Committed state, Failed state, Aborted state and Inactive state.
Exclusive lock allows only one transaction to modify data while preventing
other transactions from reading or modifying it concurrently.
UNIT – 4 LAQs
1. What is database recovery? What are the various recovery techniques?
***
Recoverability refers to the ability of a system to restore its state to a point
where the integrity of its data is not compromised, especially after a failure or
an error. It involves techniques to bring the database back to a state where
transactions are either fully committed or completely undone, ensuring data
integrity and consistency.
1. Rollback (Undo): In this technique, any uncommitted changes made by
transactions are undone by rolling back their actions. This ensures that
the database is restored to its state before the transaction began.
2. Rollforward (Redo): This technique involves re-applying committed
transactions from transaction logs to recover changes made to the
database since the last backup. It ensures that all committed changes
are reapplied to the database, bringing it up to date.
3. Database Replication: Replication involves maintaining multiple copies
of the database on different servers. In the event of a failure, one of the
replica databases can be promoted to the primary database, ensuring
continuity of service.
These recovery techniques ensure that databases can recover from various
types of failures, such as system crashes, power outages, or disk failures
23
CSD – 2B
Isolation: Isolation ensures that the data which is used at the time of
execution of a transaction cannot be used by another transaction until
the first one is executed.
24
CSD – 2B
25
CSD – 2B
26
CSD – 2B
27
CSD – 2B
7. Define Hashing.
Hashing is a technique used to search data on the disk without utilising an
indexed structure. It's commonly used in databases for efficient storage,
retrieval, and comparison of data.
UNIT – 5 LAQs
1. Explain in short, the various file organizations in DBMS. **
File organization in a Database Management System (DBMS) refers to the
way data is organized and stored on disk. Different file organizations offer
various advantages and disadvantages in terms of efficiency, ease of
access, and maintenance. Here are some common file organizations in
DBMS:
1. Heap (or Unordered) File Organization:
In a heap file organization, records are stored in an unordered
manner.
Records are inserted at the end of the file, and there is no
specific order maintained.
This approach is simple and requires minimal overhead, but it
can lead to inefficient data retrieval since records may be
scattered throughout the file.
2. Sequential File Organization:
In a sequential file organization, records are stored based on a
primary key.
This can be implemented in two ways:
Pile File method is used to store the records in a sequence which
is one after the other.
Sorted File method is used to sort the records after inserting each
new record at the end of file.
3. ISAM:
28
CSD – 2B
1. Primary Storage:
Primary storage offers quick access to the stored data.
We also know the primary storage as volatile storage.
29
CSD – 2B
30
CSD – 2B
Slower insertion and deletion due to Faster insertion and deletion as only
updates needed in multiple node leaf nodes need updating.
types
Less efficient for range scans More efficient for range scans
Leaf nodes can contain data or Leaf nodes only contain actual data
pointers to data.
4. Write the difference between static & dynamic hashing. ***
Static hashing and dynamic hashing are both techniques used in database
systems for organizing and accessing data efficiently, particularly in hash-
based indexing structures. However, they differ in their approach to handling
hash collisions and dynamically adjusting the hash structure.
31
CSD – 2B
2. Types of Indexes:
Primary Index: An index created on the primary key of a table to
enforce the primary key constraint and facilitate fast retrieval of
rows based on their primary key values.
Secondary Index: An index created on non-primary key columns
to speed up queries that don't use the primary key, improving the
performance of search conditions involving other columns.
Clustered Index: An index that reorders the physical order of
rows in the table based on the indexed column's values, resulting
in faster retrieval of rows but may require reordering the data
when the indexed column is updated.
Non-clustered Index: An index that stores the index entries
separately from the actual data rows, allowing for faster retrieval
of index entries but potentially slower retrieval of data rows.
3. Index Maintenance:
Indexes require maintenance to remain effective as the
underlying data changes.
Insertions, updates, and deletions to indexed columns may
require updating the corresponding index entries to reflect the
changes.
- 160922750086
32