dbms
dbms
3)Define Boyce Codd normal form. How does it differ from 3NF
Module 4 part b
1)Explain with examples 1NF,2NF, 3NF and BCNF.
Module 3 part a
1) Outline concept of assertion in SQL with an example
2) Explain any three differences between Hash indexes and B* tree indexes
4) Explain a situation where a multi-levelindex would be significantly less effective than a single-level
index, and vice versa.
8) A file has r :20000 STUDENT records of fixed length. Each record has the following fields: NAME
(30 bytes), SSN (9 bytes), ADDRESS (40 bytes) PHONE(9 bytes), BIRTHDATE (8 bytes), GENDER (1
byte), DEPTID (4bytes), CLASSCODE (4 bytes), and PROGID (3 bytes). An additional byte is used as a
deletion marker. The file is stored on the disk with block size 8:512 bytes, Calculate the record size R
in bytes. Calculate the blocking factor bfr and the number of file blocks by assuming an unspanned
organization. Calculate the average time it takes to find a record by doing a linear searc
Module 4 part b
1)With the help of an example explain Single-level indexing and multi-level indexing. Explain the
difference (any four) between single Level indexing and multi-level indexing.
B-Trees and B+ Trees are both widely used indexing structures in databases, but they have key
differences in how they store and retrieve data.
Data Stores both keys and data in internal Stores only keys in internal nodes; actual data is
Storage and leaf nodes. stored only in leaf nodes.
Leaf All leaf nodes are linked, forming a linked list for
Not necessarily linked.
Nodes sequential access.
Example: In a B-Tree, a key and its associated data may exist in an internal node. In contrast, in a
B+ Tree, only leaf nodes store the actual records.
2. Search Efficiency
Search Searching can end at any node, as data Searching always continues until a leaf node
Process is present in internal nodes. is reached, where data is stored.
B+ Trees are faster for range queries (e.g., finding all records between two values) because leaf
nodes are linked, making traversal efficient.
Height of Taller because internal nodes store Shorter because internal nodes store only
Tree both keys and data. keys, making branching higher.
Space Less space-efficient since data is More space-efficient as data is stored only in
Efficiency stored at multiple levels. leaves.
A B+ Tree has more keys per node, reducing the tree height and making it more balanced and
efficient.
Search Process Search may stop at any node. Search always goes to leaf nodes.
Space Less efficient, as data exists in multiple More efficient, as internal nodes only
Utilization levels. store keys.
Conclusion:
• B-Trees are better when frequent insertions and deletions are needed at various levels.
• B+ Trees are better for fast retrieval and range queries, making them widely used in
databases.
Indexing is used in databases to optimize the search process by reducing the time required to locate
records. It works similarly to an index in a book, allowing quick access to desired information.
1. Single-Level Indexing
In single-level indexing, there is only one level of index that directly maps search key values to
actual data records.
Example:
101 John 85
102 Alice 90
103 Bob 78
104 Eve 92
101 001
102 002
103 003
104 004
Here, each index entry maps the Roll No to a specific block address in the database, reducing search
time compared to a linear scan.
• If the number of records is large, the index table itself becomes too large to fit in memory.
• Searching still requires scanning the index table, which can be slow for very large datasets.
2. Multi-Level Indexing
Multi-level indexing solves the problem of large index tables by introducing multiple layers of
indexes.
Example:
If the index table in single-level indexing becomes too large, we introduce a second-level index:
101 – 150 01
151 – 200 02
201 – 250 03
101 001
102 002
103 003
104 004
1. First, search the main index table to find the block that contains the required roll number.
2. Then, search within that specific block in the secondary index to find the exact record.
Advantages of Multi-Level Indexing:
• Suitable for very large databases where the single-level index is too big to fit in memory.
Structure Contains only one index table. Has multiple levels of index tables.
Slower for large databases as index Faster as it reduces search time using
Speed
size grows. hierarchical indexing.
The Lossless Join Property (or Non-Additive Join Property) of decomposition in database
normalization ensures that when a relation is decomposed into two or more sub-relations, the
original relation can be perfectly reconstructed (i.e., joined back) using a natural join operation
without any loss of information.
Definition
A decomposition of a relation RR into sub-relations R1,R2,...,RnR_1, R_2, ..., R_n is lossless if:
This means that when we join all decomposed relations, we get back exactly the original relation
without any spurious (extra) tuples.
(R1∩R2)→R1or(R1∩R2)→R2(R_1 \cap R_2) \to R_1 \quad \text{or} \quad (R_1 \cap R_2) \to R_2
That is, the common attributes R1∩R2R_1 \cap R_2 must act as a superkey in at least one of the
decomposed relations.
Example
Lossless Decomposition
Consider a relation:
R(A,B,C)R(A, B, C)
A→BA \to B
If we decompose RR into:
The common attribute is A, and since A → B, A acts as a key in R1R_1, ensuring that the
decomposition is lossless.
Lossy Decomposition
Here, the common attribute is B, but since there is no functional dependency like B→AB \to A or
B→CB \to C, the decomposition is lossy. Joining R1R_1 and R2R_2 may introduce extra tuples.
Would you like a more detailed example with a step-by-step check for lossless decomposition?
Situations Where Multi-Level Indexing is Less Effective than Single-Level Indexing (and Vice Versa)
Indexing improves database search efficiency, but choosing between single-level and multi-level
indexing depends on factors like data size and query patterns.
• Example: A company stores employee records with less than 500 entries.
• A single-level index (one index table pointing to data records) is sufficient because the index
itself is small and can fit into memory.
• Using multi-level indexing in this case would increase complexity without providing much
benefit.
Why?
• Multi-level indexing introduces extra levels that must be traversed, adding overhead
without improving performance for small datasets.
• A single-level index would be too large to fit in memory and require scanning a huge index
table.
• Multi-level indexing optimizes the search by allowing a hierarchical lookup, reducing search
time.
Why?
• Instead of scanning a massive single-level index, a multi-level index allows faster access by
narrowing down the search at each level.
Key Takeaways
Large database (millions of Multi-Level Reduces index size in memory and speeds up
records) Index search.