Important Questions

CSC475 · Exam intelligence

Advanced Database important questions

From 3 past TU papers: which questions keep coming back, how much they carry, and what is most likely to show up next. Every question links to a model answer.

Most likely in the next examStatistical

Ranked by how often a topic is asked, its marks weight, and whether it is due after skipping the 2081 paper. No guarantees; study the whole syllabus.

1asked 2xavg 10 marks · due (skipped 2081) · Distributed Database Concepts and Advantages
Answer

Why distributed database is important? What is transparency? Explain different types of transparencies in distributed databases.[10]

--- A distributed database is a collection of multiple, logically interrelated databases distributed over a computer network. It is important for the following reasons: Organizations are naturally distributed over several geographic loca...

2asked 2xavg 5 marks · due (skipped 2081) · Aggregation
Answer

Explain aggregation with suitable example. [5]

Aggregation is a feature in the Enhanced Entity-Relationship (EER) model that allows a relationship set to participate in another relationship set. It is used when we need to express a relationship between a relationship and an entity, w...

3asked 2xavg 5 marks · due (skipped 2081) · Concept of Query Processing
Answer

Explain different steps in query processing. [5]

Query Processing is the process of executing a database query or request for information. It involves several steps that transform a high-level query written in a programming language (such as SQL) into instructions that can be understoo...

4asked 2xavg 5 marks · due (skipped 2081) · Data Fragmentation, Replication and Allocation Techniques for Distributed Database Design
Answer

Define fragmentation. Explain horizontal fragmentation with an example. [5]

Fragmentation is the process of dividing a database into smaller, manageable pieces called fragments, which can be stored at different physical locations in a distributed database system. Each fragment contains a subset of the data from ...

5asked 2xavg 5 marks · due (skipped 2081) · Introduction to NOSQL Systems
Answer

What are the characteristics of NOSQL Systems? [5]

NoSQL (Not Only SQL) systems are alternatives to traditional relational databases designed to handle large-scale, flexible, and high-performance data management. The key characteristics of NoSQL systems are as follows: --- NoSQL systems ...

Most repeated questions

Topics asked at least twice, most-asked first.

asked 3xavg 7 marks · 2081, 2080
Answer

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:

ReasonExplanation
Improved PerformanceReduces execution time of queries, making data retrieval faster
Resource UtilizationMinimizes CPU usage, disk I/O, and network traffic
Cost ReductionMinimizes resource usage and improves overall efficiency of query execution
ScalabilityTechniques like indexing, caching, and parallel processing help handle growing workloads
Complex Query SupportConsiders query rewriting, join ordering, and index selection for complex queries
Application ResponsivenessProvides 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:

  1. 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.
  2. 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.
  3. Perform the most restrictive selection and join operations first

    • Operations that eliminate the most data should be applied before less restrictive ones.
  4. 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 Tree

The optimizer:

  1. Parses the SQL query into an initial query tree (usually based on relational algebra).
  2. Applies heuristic rules to push selections and projections down the tree (closer to the leaf nodes/base relations).
  3. 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       DEPARTMENT

In 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)
         |
      EMPLOYEE

What changed:

  • The selection e.salary > 50000 is 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 ename and dname.

Benefits of This Optimization

StepWithout HeuristicWith Heuristic
JOIN input sizeFull EMPLOYEE table (e.g., 10,000 rows)Filtered EMPLOYEE (e.g., 500 rows)
Intermediate resultVery largeMuch smaller
Execution timeSlowSignificantly 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.

asked 3xavg 5 marks · 2081, 2080, 2079
Answer

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

FeatureIndexingHashing
Large DatabaseDoes not work wellWorks well
Search MethodData reference / addressMathematical hash function
Access TypeSequential / tree-basedDirect 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.

asked 3xavg 5 marks · 2081, 2080, 2079
Answer

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...

asked 2xavg 10 marks · 2080, 2079
Answer

Why distributed database is important? What is transparency? Explain different types of transparencies in distributed databases.[10]

--- A distributed database is a collection of multiple, logically interrelated databases distributed over a computer network. It is important for the following reasons: Organizations are naturally distributed over several geographic loca...

asked 2xavg 5 marks · 2080, 2079
Answer

Explain aggregation with suitable example. [5]

Aggregation is a feature in the Enhanced Entity-Relationship (EER) model that allows a relationship set to participate in another relationship set. It is used when we need to express a relationship between a relationship and an entity, w...

asked 2xavg 5 marks · 2080, 2079
Answer

Explain different steps in query processing. [5]

Query Processing is the process of executing a database query or request for information. It involves several steps that transform a high-level query written in a programming language (such as SQL) into instructions that can be understoo...

asked 2xavg 5 marks · 2080, 2079
Answer

Define fragmentation. Explain horizontal fragmentation with an example. [5]

Fragmentation is the process of dividing a database into smaller, manageable pieces called fragments, which can be stored at different physical locations in a distributed database system. Each fragment contains a subset of the data from ...

asked 2xavg 5 marks · 2080, 2079
Answer

What are the characteristics of NOSQL Systems? [5]

NoSQL (Not Only SQL) systems are alternatives to traditional relational databases designed to handle large-scale, flexible, and high-performance data management. The key characteristics of NoSQL systems are as follows: --- NoSQL systems ...

asked 2xavg 10 marks · 2081, 2079
Answer

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 Employee object can contain an Address object 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, Address is a row type that groups street, city, and zipcode into 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:

ConstructorDescription
SetAn unordered collection of unique elements (no duplicates)
ListAn 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
);

FeatureDescription
Reference TypeSpecifies object identifiers to allow one object to reference another
EncapsulationOperations are encapsulated within user-defined types
Inheritance (UNDER)New types can be derived from existing types using the UNDER keyword

Summary Table

ConceptDescription
Object IdentityUnique OID for every object
EncapsulationData + behavior bundled together
InheritanceSubclass inherits from superclass using UNDER
Complex ObjectsObjects containing other objects
OQLSQL-like language for querying objects
Row Type ConstructorGroups multiple attributes into one structured type
Collection Type ConstructorSet, List, Bag for multi-valued attributes
Reference TypeMechanism 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.

asked 2xavg 8 marks · 2081, 2079
Answer

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...

asked 2xavg 5 marks · 2081, 2079
Answer

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

PropertyDescription
ConsistencyEvery read receives the most recent write or an error. All nodes in the system see the same data at the same time.
AvailabilityEvery request receives a response (not necessarily the most recent data). The system remains operational at all times.
Partition ToleranceThe 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:

  1. CA Systems (Consistency + Availability): Sacrifice partition tolerance. Work well in single-node or non-distributed environments. Example: Traditional RDBMS.

  2. 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.

  3. 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.

asked 2xavg 5 marks · 2081, 2080
Answer

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

VDescriptionExample
VolumeHuge amount of dataPetabytes of social media data
VelocitySpeed of data generationReal-time stock transactions
VarietyDifferent types of dataText, 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.

asked 2xavg 5 marks · 2081, 2080
Answer

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

UseDescription
Business RulesEnforce complex constraints automatically
Fraud DetectionMonitor and react to suspicious transactions
Data IntegrityMaintain consistency across tables
AuditingLog all changes for tracking
Derived DataAuto-update computed/summary values
SynchronizationKeep related data consistent

Triggers make the database active rather than passive, enabling it to respond intelligently to data changes without manual intervention.

asked 2xavg 5 marks · 2081, 2079
Answer

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...

Study every one of these with model answers, flashcards, and MCQs.

Open CSC475 study modes