CSC475 · TU past paper
Advanced Database 2081 question paper
The complete TU 2081 exam paper for Advanced Database (CSC475), all 12 questions with solved model answers written to the mark scheme.
Tap a question to open its answer.
- 110 marksObject Database ConceptsHideAnswer
Explain different object database concepts in brief. What are type constructors?[10]
Object Database Concepts and Type Constructors
Part 1: Object Database Concepts
Object databases (also called Object-Oriented Databases) combine the advantages of object-oriented technologies with traditional database systems. The main goal is to improve the modeling of real-world concepts in the database.
Key Object Database Concepts
1. Object Identity
Every object in an object database has a unique, system-generated identifier called an Object Identifier (OID). Unlike relational databases where identity is based on key values, OIDs are independent of the object's attribute values and remain stable even if the data changes.
2. Complex Objects
Object databases support complex (composite) objects that can contain other objects as attributes. This allows modeling of real-world entities more naturally. For example, an
Employeeobject can contain anAddressobject as an attribute.
3. Encapsulation
Object databases support encapsulation, which means that both data (attributes) and behavior (methods/operations) are bundled together within an object. External users interact with objects only through defined interfaces. This is provided through the mechanism of user-defined types.
4. Classes and Type Hierarchy
Objects are grouped into classes based on shared attributes and methods. Classes can be organized into a type hierarchy using inheritance, allowing subclasses to inherit properties and methods from superclasses. In SQL-based object databases, this is supported using the keyword UNDER.
5. Inheritance
Inheritance allows a new class (subclass) to derive properties and behaviors from an existing class (superclass). This promotes reusability and reduces redundancy. For example:
Person (superclass) └── Employee UNDER Person (subclass) └── Student UNDER Person (subclass)
6. Object References
Objects can reference other objects using reference types. This replaces the concept of foreign keys in relational databases and allows direct navigation between related objects.
7. Polymorphism
The same operation can behave differently on different types of objects. This allows flexible and extensible database design.
8. Object Query Language (OQL)
Object databases are queried using OQL (Object Query Language), which is an SQL-like declarative language. It provides:
- High-level primitives for object sets and structures
- Support for object identity and complex objects
- Syntax similar to SQL but extended with object-oriented features
9. Persistence
Objects in an object database are persistent, meaning they continue to exist beyond the execution of the program that created them, unlike transient objects in memory.
Part 2: Type Constructors
Type constructors are mechanisms used in object-relational and object databases to define complex or structured data types beyond the basic primitive types (integer, string, etc.).
Definition
A type constructor is a mechanism that allows the creation of new, complex data types by combining or structuring existing types.
Two Main Categories of Type Constructors
1. Row Type (Tuple / Struct) Constructor
- Used to create a structured type that groups multiple attributes together, similar to a record or struct.
- Allows a single attribute to hold multiple sub-attributes.
- Example:
CREATE TYPE Address AS ( street VARCHAR(50), city VARCHAR(30), zipcode CHAR(10) ) NOT FINAL;Here,
Addressis a row type that groupsstreet,city, andzipcodeinto a single structured type.
2. Collection Type Constructor
Collection types allow an attribute to hold multiple values of the same type. There are three main collection type constructors:
Constructor Description Set An unordered collection of unique elements (no duplicates) List An ordered collection of elements (duplicates allowed) Bag (Multiset) An unordered collection where duplicates are allowed Example:
-- A SET of phone numbers for an employee CREATE TYPE PhoneSet AS SET(VARCHAR(15)); -- Using it in a table CREATE TABLE Employee ( emp_id INT, name VARCHAR(50), phones PhoneSet );
Additional Mechanisms Related to Type Constructors
Feature Description Reference Type Specifies object identifiers to allow one object to reference another Encapsulation Operations are encapsulated within user-defined types Inheritance (UNDER) New types can be derived from existing types using the UNDERkeyword
Summary Table
Concept Description Object Identity Unique OID for every object Encapsulation Data + behavior bundled together Inheritance Subclass inherits from superclass using UNDER Complex Objects Objects containing other objects OQL SQL-like language for querying objects Row Type Constructor Groups multiple attributes into one structured type Collection Type Constructor Set, List, Bag for multi-valued attributes Reference Type Mechanism for object-to-object references
Conclusion
Object database concepts extend traditional relational databases by incorporating object-oriented principles such as identity, encapsulation, inheritance, and complex types. Type constructors, specifically row type (tuple/struct) and collection type (set, list, bag) constructors, are fundamental tools that enable the definition of rich, complex data structures needed to model real-world entities accurately.
- 210 marksQuery Trees and Heuristics for Query OptimHideAnswer
Why do we need query optimization in databases? Explain heuristic query optimization with examples.[10]
Query Optimization in Databases
Why Do We Need Query Optimization?
Query optimization is essential in database systems for the following reasons:
Reason Explanation Improved Performance Reduces execution time of queries, making data retrieval faster Resource Utilization Minimizes CPU usage, disk I/O, and network traffic Cost Reduction Minimizes resource usage and improves overall efficiency of query execution Scalability Techniques like indexing, caching, and parallel processing help handle growing workloads Complex Query Support Considers query rewriting, join ordering, and index selection for complex queries Application Responsiveness Provides faster responses, leading to better user experiences
Heuristic Query Optimization
Definition
Heuristic query optimization transforms an initial query tree into a final (optimized) query tree using a set of equivalence transformation rules (heuristic rules). These rules typically improve execution performance without computing the actual cost of each alternative plan.
The internal representation of the query is usually a query tree or query graph data structure, and heuristic rules are applied to modify this structure to improve performance.
Key Heuristic Rules
The following are the most commonly applied heuristic rules:
-
Perform SELECT (selection) operations as early as possible
- Selection reduces the number of tuples in intermediate results.
- Applying it before JOIN or other binary operations reduces the size of files being joined.
-
Perform PROJECT (projection) operations as early as possible
- Projection reduces the number of attributes (columns) in intermediate results.
- This reduces the size of tuples flowing through the query tree.
-
Perform the most restrictive selection and join operations first
- Operations that eliminate the most data should be applied before less restrictive ones.
-
Apply SELECT before JOIN or other binary operations
- This is the main heuristic rule: since SELECT and PROJECT reduce file size, they should always precede JOIN operations.
How Heuristic Query Optimizer Works
Initial Query Tree | v Apply Equivalence Transformation Rules (Heuristics) | v Final Optimized Query TreeThe optimizer:
- Parses the SQL query into an initial query tree (usually based on relational algebra).
- Applies heuristic rules to push selections and projections down the tree (closer to the leaf nodes/base relations).
- Produces a final query tree that is expected to execute more efficiently.
Example
Consider the following query:
SELECT e.ename, d.dname FROM EMPLOYEE e, DEPARTMENT d WHERE e.dno = d.dnumber AND e.salary > 50000;Step 1: Initial Query Tree (Naive Plan)
The naive approach applies operations in the order they appear:
PROJECT (e.ename, d.dname) | SELECT (e.salary > 50000) | JOIN (e.dno = d.dnumber) / \ EMPLOYEE DEPARTMENTIn the naive plan, the JOIN is performed first on the full EMPLOYEE and DEPARTMENT tables, producing a large intermediate result. Then the SELECT filter is applied.
Step 2: Apply Heuristic Rules
Rule Applied: Push the SELECT operation below the JOIN (apply it early, before the JOIN).
Step 3: Final Optimized Query Tree
PROJECT (e.ename, d.dname) | JOIN (e.dno = d.dnumber) / \ SELECT DEPARTMENT (e.salary > 50000) | EMPLOYEEWhat changed:
- The selection
e.salary > 50000is now applied directly on EMPLOYEE before the JOIN. - This filters out employees with salary <= 50000 first, producing a much smaller intermediate relation.
- The JOIN is then performed on this smaller EMPLOYEE result and the DEPARTMENT table.
- Finally, PROJECT reduces the attributes to only
enameanddname.
Benefits of This Optimization
Step Without Heuristic With Heuristic JOIN input size Full EMPLOYEE table (e.g., 10,000 rows) Filtered EMPLOYEE (e.g., 500 rows) Intermediate result Very large Much smaller Execution time Slow Significantly faster
Summary
Heuristic query optimization is a rule-based approach that improves query performance by transforming the query tree. The core principle is:
"Apply SELECT and PROJECT early to reduce intermediate result sizes before performing expensive JOIN operations."
Unlike cost-based optimization (which uses statistics and computes actual costs), heuristic optimization applies general rules that are known to improve performance in most cases, making it simpler and faster to apply.
-
- 310 marksDistributed Database ArchitecturesHideAnswer
Explain different distributed database architectures. What is data fragmentation?[10]
A distributed database system (DDBS) is a collection of logically interrelated databases distributed over a computer network, where data is stored across multiple nodes and managed as a single unified system. --- In a homogeneous distrib...
- 45 marksConstraints and characteristics of specialHideAnswer
Explain different constraints of specialization and generalization. [5]
Specialization and Generalization are key concepts in the Enhanced Entity-Relationship (EER) model. There are two main constraints that apply to both specialization and generalization: --- This constraint specifies whether every entity i...
- 55 marksConcepts of File Structures, Hashing, and HideAnswer
What is hashing? How does hashing improve database efficiency? [5]
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.
- 65 marksThe ODMG Object Model and the Object DefinHideAnswer
Explain ODMG object model. [5]
ODMG stands for Object Data Management Group. It is a standard data model upon which the Object Definition Language (ODL) and Object Query Language (OQL) are based. It is designed to provide a standard data model for object-oriented data...
- 75 marksQuery Trees and Heuristics for Query OptimHideAnswer
What are the uses of query trees in query processing? Explain. [5]
Uses of Query Trees in Query Processing
Definition
A query tree is a hierarchical (tree-based) representation of the steps and operations involved in executing a database query. It outlines the logical and physical operations required to retrieve the desired data from the database.
Uses of Query Trees in Query Processing
1. Visualization and Understanding
Query trees provide a visual representation of the query execution plan. This makes it easier for database administrators, developers, and optimizers to understand and analyze the sequence of steps involved in processing a query. Instead of reading complex procedural instructions, one can simply trace the tree from leaves (base relations) to the root (final result).
2. Query Optimization
By representing the query execution plan as a tree, the query optimizer can efficiently explore and evaluate various alternative plans. It can rearrange nodes, reorder operations (such as pushing selections down the tree), and compare costs of different plans to select the most efficient execution strategy. This directly helps in minimizing execution time and resource consumption.
3. Execution Order and Data Flow
Query trees define the order in which operations (such as selection, projection, join) are performed and how data flows between them. Each internal node represents an operation, and data flows upward from child nodes to parent nodes, making the execution sequence explicit and unambiguous.
4. Query Plan Caching and Reuse
Query trees can be cached and reused for similar queries that differ only in parameter values. When the same or a structurally similar query is submitted again, the stored query tree can be retrieved and reused, avoiding the overhead of re-parsing and re-optimizing. This significantly improves query performance.
5. Support for Complex Queries
Query trees help in managing and processing complex queries involving multiple joins, subqueries, and nested operations. By breaking down a complex query into a structured tree of simpler operations, the system can handle each operation systematically and efficiently.
Summary Table
Use Benefit Visualization Easier understanding of execution plan Query Optimization Finds the most efficient execution strategy Execution Order & Data Flow Defines clear operation sequence Plan Caching & Reuse Avoids redundant computation Complex Query Support Manages multi-step queries systematically
In summary, query trees are a fundamental tool in query processing that bridge the gap between a high-level SQL query and its efficient execution by the DBMS.
- 85 marksThe CAP TheoremHideAnswer
What is the CAP theorem? Explain. [5]
CAP Theorem
Definition
The CAP Theorem (also known as Brewer's Theorem) is a theoretical framework in distributed database systems. CAP stands for:
- C - Consistency
- A - Availability
- P - Partition Tolerance
The theorem states that a distributed database system can guarantee at most two out of these three properties simultaneously - it is impossible to achieve all three at the same time.
Explanation of the Three Properties
Property Description Consistency Every read receives the most recent write or an error. All nodes in the system see the same data at the same time. Availability Every request receives a response (not necessarily the most recent data). The system remains operational at all times. Partition Tolerance The system continues to operate even when network partitions (communication breakdowns between nodes) occur.
Classification of Distributed Systems
Based on the CAP theorem, distributed systems are classified into three categories:
-
CA Systems (Consistency + Availability): Sacrifice partition tolerance. Work well in single-node or non-distributed environments. Example: Traditional RDBMS.
-
CP Systems (Consistency + Partition Tolerance): Sacrifice availability. When a partition occurs, the system may refuse to respond rather than return inconsistent data. Example: HBase, MongoDB.
-
AP Systems (Availability + Partition Tolerance): Sacrifice consistency. The system remains available even during partitions but may return stale data. Example: Cassandra, CouchDB.
Significance in NoSQL
The CAP theorem is especially important for understanding NoSQL systems. NoSQL databases cannot provide all three guarantees together, so designers must choose which two properties are most critical for their use case. This trade-off guides the selection of the appropriate NoSQL database for a given application.
- 95 marksBigDataHideAnswer
What is Big Data? What are its 3 V’s? [5]
Big Data and Its 3 V's
What is Big Data?
Big Data refers to extremely large and complex datasets that cannot be processed, stored, or analyzed using traditional data management tools and conventional database systems within a reasonable amount of time.
Big Data encompasses data that is generated at high speed from a wide variety of sources such as social media platforms, sensors, transaction records, multimedia files, and IoT devices. The volume of this data is so massive that standard relational database systems (like those discussed in DBMS) are insufficient to handle it efficiently.
The 3 V's of Big Data
The 3 V's are the three defining characteristics that describe Big Data:
1. Volume
- Refers to the enormous amount of data generated every second from various sources.
- Data is measured in terabytes, petabytes, exabytes, and beyond.
- Example: Facebook generates hundreds of terabytes of data daily.
- The sheer size makes it impossible to store and process using traditional systems.
2. Velocity
- Refers to the speed at which data is generated, collected, and processed.
- Data streams in at an unprecedented rate and must often be processed in real-time or near real-time.
- Example: Stock market transactions, live social media feeds, sensor data from IoT devices.
- High velocity demands fast processing frameworks (e.g., Apache Kafka, Spark Streaming).
3. Variety
- Refers to the different types and formats of data being generated.
- Data can be:
- Structured - data in tables/rows (e.g., relational databases, SQL data)
- Semi-structured - data like XML, JSON files
- Unstructured - data like images, videos, audio, emails, social media posts
- Managing such diverse data types is a major challenge in Big Data.
Summary Table
V Description Example Volume Huge amount of data Petabytes of social media data Velocity Speed of data generation Real-time stock transactions Variety Different types of data Text, images, videos, logs
In modern Big Data discussions, two additional V's are often added: Veracity (accuracy/trustworthiness of data) and Value (usefulness of data), making it the 5 V's model.
- 105 marksActive Database Concepts and TriggersHideAnswer
What are triggers? What are the uses of triggers? [5]
Triggers in Database Systems
Definition of Triggers
A trigger is a special type of stored procedure (or rule) in a database that is automatically executed (fired) in response to certain events occurring on a specified table or view. Triggers are a core component of active databases, where the database itself can react to changes without requiring explicit user commands.
A trigger is defined using the general form:
Event --> Condition --> Action (ECA Model)- Event: An operation that fires the trigger (INSERT, UPDATE, DELETE)
- Condition: An optional check that must be satisfied
- Action: The procedure that executes when the trigger fires
Uses of Triggers
1. Enforcing Business Rules
Triggers automatically enforce complex business rules that cannot be handled by simple constraints. For example, ensuring that a bank account balance never goes below zero after a withdrawal.
2. Fraud Detection and Security Monitoring
In a banking system, triggers can monitor customer transactions and detect potential fraud activities, such as:
- A high-value transaction exceeding a threshold
- A series of unusual transactions from the same account at different locations within a short period
- The trigger fires automatically and can alert the system or block the transaction.
3. Maintaining Data Integrity
Triggers ensure referential integrity and consistency across related tables, especially in situations where foreign key constraints alone are insufficient.
4. Automatic Auditing and Logging
Triggers can automatically record changes (INSERT, UPDATE, DELETE) made to sensitive tables into an audit log table, keeping a history of all modifications for accountability.
5. Derived Data Maintenance
Triggers can automatically update derived or summary data. For example, when a new sale is recorded, a trigger can automatically update the total sales figure in a summary table.
6. Replication and Synchronization
Triggers can be used to keep multiple copies of data synchronized by propagating changes from one table to related tables automatically.
Summary Table
Use Description Business Rules Enforce complex constraints automatically Fraud Detection Monitor and react to suspicious transactions Data Integrity Maintain consistency across tables Auditing Log all changes for tracking Derived Data Auto-update computed/summary values Synchronization Keep related data consistent Triggers make the database active rather than passive, enabling it to respond intelligently to data changes without manual intervention.
- 115 marksSpatial Database ConceptsHideAnswer
Why do we need spatial databases? What are common types of analysis for spatial data? [5]
A spatial database is a database that is optimized to store and query data related to objects in space, including points, lines, polygons, and geographic features (maps, locations, regions). We need spatial databases for the following re...
- 125 marksMapReduceHideAnswer
Write short notes on: a) Map Reduce b) Multimedia database [5]
--- MapReduce is a programming model and processing framework designed for processing and generating large datasets in a distributed computing environment. It allows parallel processing of massive amounts of data across a cluster of comp...