Chapter 1
Introduction to Database Systems and Data Models
TU BBM past exam questions
Past questions and answers
8 questions set from this chapter. Most repeated first.
- 2016 · COM 312: Database Management · 5 marks
Brief Answer Questions: [5 × 1 = 5]
i. Why is relational database?
ii. What do you mean by attributes?
iii. List three domain types found in SQL.
iv. What do you mean by closure of attribute?
v. What is loss less decomposition?
Answer
i. Why is relational database? A relational database is so called because it stores data in relations (tables) — two-dimensional structures of rows (tuples) and columns (attributes) — and the tables are linked to one another through common key fields (primary key–foreign key relationships). The term "relational" comes from this tabular, relation-based model proposed by E. F. Codd, not from the relationships between tables alone.
ii. What do you mean by attributes? Attributes are the columns (fields) of a relation that describe the properties or characteristics of an entity. For example, in a Student relation, Roll_No, Name, and Address are attributes. Each attribute has a domain (set of permitted values), and the set of all attributes defines the structure (schema) of the relation.
iii. List three domain types found in SQL.
- Character/String types — CHAR, VARCHAR, TEXT
- Numeric types — INTEGER, SMALLINT, DECIMAL/NUMERIC, FLOAT/REAL
- Date and Time types — DATE, TIME, TIMESTAMP (Also acceptable: Boolean type — BOOLEAN.)
iv. What do you mean by closure of attribute? The closure of a set of attributes, written , is the set of all attributes that can be functionally determined from using the given set of functional dependencies . It is computed by repeatedly applying Armstrong's axioms (mainly reflexivity and transitivity) until no new attribute can be added. Attribute closure is used to test whether is a candidate key and to check whether a functional dependency is implied by .
v. What is lossless decomposition? A decomposition of a relation into and is lossless (non-lossy) if the natural join of the decomposed relations gives back exactly the original relation, i.e. — no tuples are lost and no spurious tuples are generated. It is guaranteed when the common attributes of and form a superkey of at least one of them ( or ).
Answer checked by Claude Haiku · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2016 · COM 312: Database Management · 3 marks
Normalize given relation to third normal form: R (A, B, C, D, E);
Primary key (A, B)
FDs given, C→D and C→E
Answer
Given: R(A, B, C, D, E), primary key (A, B), FDs: C → D, C → E.
1NF: All attributes are atomic, so R is in 1NF.
2NF: Prime attributes are {A, B}; non-prime attributes are {C, D, E}. A partial dependency needs a non-prime attribute to depend on a proper subset of the key (A alone or B alone). The given FDs have the non-prime attribute C as determinant, so there is no partial dependency. R is in 2NF.
3NF: D and E depend on C, and C depends on the key, so
These are transitive dependencies of non-prime attributes on the key, so R is not in 3NF.
Decomposition into 3NF:
- R1 (A, B, C), key (A, B)
- R2 (C, D, E), key C
In R1 the only non-prime attribute C depends directly on the key. In R2, D and E depend directly on the key C. Both relations are in 3NF (in fact BCNF). The decomposition is lossless, since the common attribute C is the key of R2, and dependency-preserving, since C → D and C → E are both in R2.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2016 · COM 312: Database Management · 3 marks
What is set membership? How is set membership found using SQL statement?
Answer
Set membership means testing whether a particular value belongs to a given set of values. In database terms, it checks whether a value in a column matches any value in a specified list (or the result of a subquery).
Finding set membership using SQL: The IN operator is used. It returns TRUE if the value matches any element of the specified set.
Syntax:
SELECT column_list
FROM table_name
WHERE column_name IN (value1, value2, ...);
Example: To find students whose faculty is either 'BBM' or 'BBA':
SELECT *
FROM Student
WHERE Faculty IN ('BBM', 'BBA');
This is equivalent to WHERE Faculty = 'BBM' OR Faculty = 'BBA', but the IN form is shorter and clearer. The NOT IN operator tests the opposite — that the value belongs to none of the listed values.
Answer checked by Claude Haiku · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2016 · COM 312: Database Management · 3 marks
Write an example for serializable transactions.
Answer
Example of Serializable Transactions
Serializable means that even when transactions run concurrently, the final result is the same as if they had run one after another (serially) in some order. The system is allowed to interleave operations, but the outcome must be equivalent to some serial order.
Example: Two Transactions on a Bank Account
Initial balance of account A = Rs 1000.
| T1 | T2 |
|---|---|
| read(A) | |
| A = A − 100 | |
| write(A) | |
| read(A) | |
| A = A + 200 | |
| write(A) |
Interleaved (concurrent) execution:
- T1 reads A → 1000
- T1 computes A = 900
- T2 reads A → 1000
- T2 computes A = 1200
- T1 writes A = 900
- T2 writes A = 1200
Final balance = Rs 1200 → the −100 update is lost (lost update problem). This schedule is not serializable.
Serializable Version
If the same two transactions are executed serially, say T1 first then T2:
- After T1: A = 1000 − 100 = 900
- After T2: A = 900 + 200 = 1100
Final balance = Rs 1100, which is the correct result.
Conclusion
A schedule is serializable when its effect equals that of running the transactions in some serial order. In the example above, the interleaved schedule gives Rs 1200 (wrong), while the serial schedule gives Rs 1100 (correct). Hence the serial schedule is the serializable one, and concurrency control (e.g., locking) must be used to prevent the non-serializable interleaving.
Answer checked by Claude Haiku · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2016 · COM 312: Database Management · 3 marks
How CHECK clause can be used to create domain constraint while creating table using SQL? Explain.
Answer
CHECK clause as a domain constraint
The CHECK clause is used to restrict the values that a column (or a group of columns) can accept. It defines a condition that every row must satisfy whenever data is inserted or updated. If the condition evaluates to FALSE, the row is rejected. This is how a domain constraint — a limit on the set of legal values for an attribute — is enforced in SQL.
Syntax
CREATE TABLE table_name (
column_name datatype [CONSTRAINT constraint_name] CHECK (condition),
...
);
Example 1 — restricting the range of a single column
CREATE TABLE Student (
Sid INT PRIMARY KEY,
Name VARCHAR(30) NOT NULL,
Age INT CHECK (Age >= 16 AND Age <= 30),
Gender CHAR(1) CHECK (Gender IN ('M', 'F'))
);
Here the domain of Age is limited to 16–30 and the domain of Gender to 'M' or 'F'. Inserting Age = 12 or Gender = 'X' gives an error and the row is not inserted.
Example 2 — named constraint
CREATE TABLE Account (
AccNo INT PRIMARY KEY,
Balance DECIMAL(10,2) CONSTRAINT chk_bal CHECK (Balance >= 500)
);
Naming the constraint makes it easier to identify and later drop or modify it.
Key points
- CHECK enforces a domain constraint because it defines the valid value set for a column, just like a data type but with user-defined logic.
- The condition may use comparison operators,
BETWEEN,IN,LIKE, and logical operators (AND,OR,NOT). - A CHECK constraint can also be applied at the table level to compare two or more columns, e.g.
CHECK (JoinDate < ResignDate). - It is checked on every
INSERTandUPDATE; a NULL value normally passes the check unless the condition explicitly excludes NULL. - It cannot reference another table or use subqueries — for such cross-table restrictions a foreign key or trigger is needed.
Answer checked by Claude Haiku · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2016 · COM 312: Database Management · 3 marks
Consider a relation R with the schema R (A, B, C, D, E, F) with a set of functional dependencies F as follows;
{AB → C, BC → AD, D → E, CF → B}
Find the super key for this relation.
Answer
Given
Compute closures:
So is a super key. Since neither nor alone determines all attributes, is a candidate key.
Also,
So is also a super key. Its proper subsets , , are not super keys, so is also a candidate key.
Therefore,
- Candidate keys: and
- Super keys: any set containing or , e.g. , , , , , , , etc.
The minimal super keys are and .
Answer checked by Claude Haiku · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2016 · COM 312: Database Management · 10 marks
Why is operational data need cleaning before performing actual data analysis? Explain the data cleaning steps showing the relation between data integrity and data quality.
Answer
Answer (10 marks)
Why operational data needs cleaning before analysis
Operational data is the raw data captured day to day by transaction systems (billing, sales, inventory, HR, banking). It is collected to run the business, not to analyse it, so it is rarely in a form fit for analysis. Cleaning is needed because:
- Incomplete data – Missing customer age, blank phone numbers, missing sales region, or absent values where a field was skipped at entry.
- Inconsistent data – The same thing stored differently: "Kathmandu", "KTM", "kathmandu"; dates as 12/03/2024 in one table and 2024-03-12 in another; units in kg in one branch and pound in another.
- Inaccurate / erroneous data – Wrong entries such as age = 250, negative quantity sold, a price of Rs 0, or a PIN code of the wrong length.
- Duplicate records – The same customer or invoice entered twice due to double entry or system re-posting.
- Outliers and noise – Extreme values caused by data-entry mistakes or measurement error, which distort averages and models.
- Irrelevant / stale data – Columns and old records not needed for the current question, which slow processing and add confusion.
- Wrong format / structural problems – Values stored as text instead of numbers, merged columns, trailing spaces, or data spread across many tables.
Consequences if not cleaned: "garbage in, garbage out" — wrong averages, misleading dashboards, biased forecasts, faulty segmentation, wrong business decisions, and loss of trust in the analytics team. Cleaning typically consumes 60–80% of an analyst's time precisely because of this.
Data cleaning steps
| Step | Activity | Typical techniques |
|---|---|---|
| 1. Data profiling / auditing | Inspect the raw data to find its problems | Summary statistics, frequency counts, null counts, min/max, duplicate checks |
| 2. Handling missing values | Deal with blanks and nulls | Drop the record/column, or impute with mean/median/mode, or a model-based value |
| 3. Removing duplicates | Identify and remove repeated rows | Exact match, fuzzy match on name + address + phone |
| 4. Standardisation | Make values uniform | Fix casing, spelling, date format (YYYY-MM-DD), units, currency, address format |
| 5. Correcting errors / validation | Fix impossible or invalid values | Range checks, cross-field checks (age vs. date of birth), referential checks |
| 6. Treating outliers and noise | Decide keep, cap, or remove | IQR / z-score detection, winsorising, binning, smoothing |
| 7. Transformation & integration | Convert to analysis-ready form | Normalisation, encoding, merging tables, deriving new fields |
| 8. Final verification & documentation | Confirm the data is clean and record what was done | Re-run profiling, row counts, data-cleaning log/audit trail |
Relation between data integrity and data quality
- Data quality is fitness for use — measured by dimensions such as accuracy, completeness, consistency, timeliness, validity, and uniqueness.
- Data integrity is the trustworthiness and wholeness of the data over its life — that it is not lost, altered, or corrupted, and that relationships (primary key–foreign key) and business rules hold true. It is maintained by constraints, validation at entry, access control, and audit trails.
The relation is one of mutual dependence:
- Integrity is the foundation of quality. If integrity is broken — a foreign key points to a non-existent customer, a record is silently overwritten, or a field is corrupted — the data cannot be accurate or consistent, so quality automatically fails. Cleaning cannot recover information that integrity controls never captured.
- Quality is the evidence of integrity. High quality (few duplicates, valid ranges, consistent formats) shows that integrity rules were enforced at the source.
- Cleaning is the bridge between them. Cleaning detects integrity violations (orphan records, duplicates, impossible values) and repairs them, thereby raising quality. But cleaning is a corrective measure; integrity must be preventive — enforced at data entry and in the database — otherwise the same errors return with the next batch of operational data.
Conclusion: Operational data must be cleaned because it is captured for transaction processing, not analysis, and therefore carries missing, inconsistent, duplicate, and erroneous values. Following the eight cleaning steps above converts it into reliable input. Data integrity and data quality are two sides of the same coin — integrity keeps the data whole and trustworthy, quality makes it fit for analysis, and only when both are ensured can data analysis produce correct and dependable business insights.
Answer checked by Claude Haiku · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2016 · COM 312: Database Management · 10 marks
What do you mean by data recovery? Discuss the situations where data need to be recovered. Explain anyone of the database recovery method.
Answer
Data recovery is the process of restoring a database to a correct, consistent state after a failure (hardware crash, software error, or human mistake) so that the lost or damaged data can be used again. In a DBMS, recovery means using the transaction log and backup copies to undo incomplete transactions and redo committed ones, guaranteeing the ACID properties — especially atomicity and durability.
Situations where data need to be recovered
- Transaction failure — a transaction aborts midway (deadlock, constraint violation, division by zero). Its partial changes must be undone.
- System crash (software failure) — the operating system or DBMS crashes, main memory (buffers) is lost, but the disk survives. Committed transactions must be redone and uncommitted ones undone.
- Media / disk failure — the hard disk is physically damaged or corrupted. Data must be restored from a backup and brought up to date using the log.
- Power failure — sudden loss of electricity leaves transactions half-completed in the buffer.
- Human error — a user or DBA deletes a table or issues a wrong update; recovery restores the earlier state.
- Malicious damage / virus attack — data is deliberately destroyed or encrypted and must be rebuilt from backups.
- Natural disaster — fire, flood or earthquake destroys the storage device, requiring off-site backup recovery.
- Concurrent access problems — deadlock or lost-update situations leave the database inconsistent.
Database recovery method — Log-Based Recovery
The most widely used method is log-based recovery, which keeps a sequential log on stable storage recording every change. Each log record contains the transaction ID, data item, old value and new value, e.g.:
Two operations are used:
- UNDO — reverses the effect of an uncommitted transaction by writing the old values back.
- REDO — re-applies the effect of a committed transaction by writing the new values again.
Deferred update (NO-UNDO/REDO): updates are written to the database only after the transaction commits. So on recovery only REDO of committed transactions is needed; no UNDO is required.
Immediate update (UNDO/REDO): updates may be written to the database before commit. On recovery, transactions that committed are REDOne and those that did not are UNDOne.
Checkpoint: periodically the DBMS writes all modified buffers to disk and records a checkpoint in the log. During recovery, only transactions after the last checkpoint need to be examined, which greatly reduces recovery time.
Example: Suppose the log shows:
| Log record | Meaning |
|---|---|
| start | begins |
| , A, 100, 200 | A changed 100 → 200 |
| start | begins |
| , B, 50, 80 | B changed 50 → 80 |
| commit | committed |
| crash | system fails |
On restart, is in the commit list → REDO it (A = 200). has no commit record → UNDO it (B = 50). The database is thus returned to a consistent state.
In short, data recovery is essential because failures are unavoidable; the log-based method with checkpoints provides an efficient, reliable way to restore the database to its last consistent state.
Answer checked by Claude Haiku · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
Questions from TU BBM past exam paper (BBM / Sixth Semester · COM 312: Database Management · 2016). Answers are written for this site; check them against your class notes.