DBMS B
DBMS B
What is the key difference between a primary index and a secondary index in a
database System?
❖ The main difference between a primary index and a secondary index in a database
management system (DBMS) is that a primary index is used to uniquely identify
records, while a secondary index is used to improve query performance.
2. Consider a B+ tree in which the maximum number of keys in a node is 5. What is
the minimum number of keys in any non-root node?
❖ The maximum number of keys per node is 5.
To find the minimum number of keys in any non-root node, we need to calculate
⌈(m+1)/2⌉, where m = 5.
⌈(5+1)/2⌉ = ⌈3⌉ = 3
Therefore, the minimum number of keys in any non-root node of a B⁺ tree with a
maximum of 5 keys per node is 3.
3. Given a B-tree where each node can contain at most 5 keys, determine the
order of the B-tree
The main difference between shared and exclusive locks is that shared locks allow
multiple transactions to read data, while exclusive locks allow only one transaction to
modify data:
Shared locks
Allow multiple transactions to read the same data, but prevent any transaction from
modifying it. Shared locks are also known as read-only locks.
Exclusive locks
Allow a transaction to modify the data, but prevent any other transaction from reading
or modifying it. Exclusive locks are also known as read and write locks.
Data security
DBMS provides multiple levels of security authentication at the user and admin levels to
help avoid security breaches.
Data integrity
DBMS ensures the consistency and accuracy of data within the database by enforcing
rules and constraints on the data.
Data sharing
DBMS provides quick solutions to database queries, enabling faster access to more
accurate data.
DBMS provides a separate process for backing up and recovering data from that of a
network backup.
Scalability
DBMS can manage huge workloads, more concurrent users, and complex queries.
Concurrent access
2. Compare the use of primary and foreign key constraints in ensuring data integrity.
❖ Primary and foreign key constraints are both important for ensuring data integrity in
a database:
Primary key constraints
Ensure that each record in a table is unique, preventing duplicate entries. A primary
key is a column or combination of columns that uniquely identifies each row in a
table.
Foreign key constraints
Establish and enforce a link between the data in two tables. A foreign key is a
column or combination of columns that references the primary key in another table.
3.Consider a relation R(A, B, C, D, E, F) with the following functional dependencies.
Determine the
❖ A JOIN is a means for combining fields from two tables by using values common to
each. Subqueries can be slower than JOINs, especially if the subquery returns a
large number of rows. JOINs are generally faster than subqueries, especially for
large datasets.
❖ Data points that belong to small or very sparse clusters or that are far away from
their assigned cluster can be considered anomalies. Density-based methods like
Expectation Maximization are used to identify data points in dense regions as
normal and those in low-density regions as anomalies.
Purpose: The Cartesian product is a building block for more complex operations, such as
joins.
How it works: The Cartesian product combines every row from one table with every row
from another table. The result is a new table where each combination has its own row.
Also known as: The Cartesian product is also called the cross product or cross join.
❖ In a relation, the degree is the number of attributes or columns, while the cardinality
is the number of tuples or rows:
Degree
The number of attributes or columns in a relation is called the degree of the relation.
It is also sometimes called the arity or width.
Cardinality
The number of tuples or rows in a relation is called the cardinality of the relation. It is
sometimes called the size or row count.
❖ A dense index in databases is a file with pairs of keys and pointers for every record in
the data file. Every key in this file is associated with a particular pointer to a record in
the sorted data file. In clustered indices with duplicate keys, the dense index points
to the first record with that key.
Maintains relationships
RI ensures that each foreign key in a child table corresponds to a primary key in the
parent table. This helps maintain accurate relationships and data flow.
Prevents errors
RI prevents users from navigating to “dead ends” and helps prevent incorrect records
from being added, deleted, or modified.