Advanced Database · Unit 1 · 8 hrs
Enhanced Entity Relationship Model and Relational Model
Exam-focused notes for Enhanced Entity Relationship Model and Relational Model (Advanced Database, CSC475): what the TU syllabus asks and how it has actually been tested, with 8 solved past questions from this unit.
Enhanced Entity Relationship Model and Relational Model in short
This unit extends the entity relationship model into the Enhanced ER (EER) model, which adds subclasses, specialization, generalization, union types and aggregation for modeling complex structures, and then shows how both the plain ER model and the EER model are mapped down into relational tables.
What this unit covers
- Entity Relationship Model Revised
- Subclasses, Superclasses and Inheritance
- Specialization and Generalization
- Constraints and characteristics of specialization and Generalization
- Union Types
- Aggregation
- Relational Model Revised
- Converting ER and EER Model to Relational Model
- SQL and Advanced Features
- Concepts of File Structures, Hashing, and Indexing
Constraints and characteristics of specialization and Generalization
2081 · 5 marks
Explain different constraints of specialization and generalization. [5]
2079 · 10 marks
Design an EER model for library management system having generalization and specialization hierarchies. The EER model should have disjoint and overlapping constraints with at least one of the entities having total participation. Use your own assumption for other concepts. Now convert the EER diagram into its equivalent relational model.[10]
Concepts of File Structures, Hashing, and Indexing
2081 · 5 marks
What is hashing? How does hashing improve database efficiency? [5]
Show solved answerHide answer
Hashing in Database Systems
Definition of Hashing
Hashing is a technique used to search the location of desired data on disk. It uses a mathematical function called a hash function to calculate the direct location (address) of a data record stored in data blocks (also called data buckets) on disk, without the need for indexing.
The hash function can select any column value to generate the address of the data block, but it usually uses the primary key to generate the address.
Formula concept:
Hash Address = hash_function(key value)
How Hashing Improves Database Efficiency
1. Direct Record Access
In large databases, searching through all indexes to find required data is time-consuming. Hashing allows the system to directly compute the disk address of a data record, eliminating the need to scan indexes or perform sequential searches.
2. Faster Data Retrieval
Since the hash function immediately points to the location of the data block, records are retrieved much faster compared to traditional search methods. This directly reduces query execution time.
3. Works Well for Large Databases
Unlike indexing, which does not work well for large databases, hashing works well for large databases because the hash function provides a constant-time lookup regardless of the size of the data.
4. Reduced Disk I/O
By jumping directly to the correct data bucket, hashing minimizes the number of disk read operations, which reduces disk I/O overhead and improves overall system performance.
5. Types of Hashing for Flexibility
Hashing supports two types:
- Static Hashing: Fixed number of buckets; suitable when data size is known.
- Dynamic Hashing: Buckets grow or shrink as data changes; suitable for dynamic datasets.
Comparison: Indexing vs Hashing
| Feature | Indexing | Hashing |
|---|---|---|
| Large Database | Does not work well | Works well |
| Search Method | Data reference / address | Mathematical hash function |
| Access Type | Sequential / tree-based | Direct address computation |
Summary
Hashing improves database efficiency by providing direct, fast, and computed access to data records on disk using a hash function, thereby reducing search time, minimizing disk I/O, and improving overall database performance especially for large-scale systems.
2080 · 5 marks
Why hashing is important to store data in databases? What is primary file organization? [5]
2079 · 5 marks
Why indexing is important to store data in database? What's multilevel index? [5]
Show solved answerHide answer
Importance of Indexing in Database and Multilevel Index
Why Indexing is Important (2.5 marks)
When executing SQL queries, it takes some amount of time to access data from the disk. An index is a data structure that helps to find and access data in a table of a database quickly. Indexing technique reduces the number of disk accesses required to process queries.
The key reasons why indexing is important are:
| Reason | Explanation |
|---|---|
| Faster Data Retrieval | Index allows the database engine to locate data without scanning every row in a table |
| Reduced Disk I/O | Fewer disk accesses are needed, which significantly speeds up query execution |
| Query Optimization | Indexing is one of the core optimization techniques that minimizes CPU usage, disk I/O, and network traffic |
| Scalability | Helps the system handle growing workloads while maintaining consistent performance |
| Efficient Searching | Ordered indexing sorts data, making searching faster and more structured |
Without indexing, the database would perform a full table scan for every query, which is extremely slow for large databases.
Multilevel Index (2.5 marks)
Definition
A multilevel index is an indexing scheme where the index itself is further indexed at multiple levels, creating a hierarchy of indexes. It is used when a single-level index becomes too large to fit in memory or becomes inefficient to search.
Why Multilevel Index is Needed
- In a large database, it is not possible to search all the indexes at once to obtain the required data.
- A single-level index on a very large table can itself become very large, making the index search slow.
- Multilevel indexing solves this by creating an index over the index, reducing the search space at each level.
Structure
Level 3 (Top/Outer Index) --> very small, fits in memory
|
Level 2 (Intermediate Index)
|
Level 1 (Inner/Base Index)
|
Actual Data Blocks
- Level 1 (Primary Index): Index on the actual data file.
- Level 2 (Secondary Index): Index on the Level 1 index, further reducing search space.
- Level 3 and beyond: Further levels are added as needed until the top-level index fits in a single disk block or memory.
Key Points
- Each level reduces the number of entries to be searched.
- The top-level index is small enough to be loaded into main memory.
- Multilevel indexing is the foundation of B-Tree and B+ Tree index structures commonly used in DBMS.
- Secondary indexing contains another level of indexing to minimize the size of mapping, which is a basic form of multilevel indexing.
Example
If a table has 1,000,000 records and each index block holds 100 entries:
- Level 1 index: 10,000 blocks
- Level 2 index: 100 blocks
- Level 3 index: 1 block (fits in memory)
This reduces disk accesses from potentially 1,000,000 to just 3 levels, demonstrating the efficiency of multilevel indexing.
In summary, indexing is critical for fast and efficient data retrieval in databases, and multilevel indexing extends this concept to handle very large datasets by organizing indexes in a hierarchical manner, minimizing disk accesses at every level.
Specialization and Generalization
2080 · 10 marks
Explain different features of enhanced ER(EER) model. Compare specialization with generalization.[10]
Aggregation
Make Unit 1 stick
Practice CSC475 with flashcards & quizzes