πŸ“š Computer β€” Computer

Query Languages, Data Modification, Searching, Sorting, Reports, Forms & Backup in Databases (Database 2)

Database Models, Keys, Relational Algebra, SQL, Security & Concurrency Control

One-Liner Questions

What is the core concept of the ER Model (Entity-Relationship Model)?
A conceptual data modeling tool developed by Peter Chen in 1976 that represents real-world objects as Entities, Attributes, and Relationships.
Tap to view answer
Which geometric shape represents an 'Entity Set' in an ER Diagram?
A Rectangle box.
Tap to view answer
Which shapes represent an Attribute and a Relationship in an ER Diagram?
An Attribute is represented by an Ellipse/Oval, and a Relationship is represented by a Diamond/Rhombus.
Tap to view answer
How are a Weak Entity and its identifying relationship represented in an ER Diagram?
A Weak Entity is represented by a Double Rectangle, and its identifying relationship is represented by a Double Diamond.
Tap to view answer
How are a Multivalued Attribute and a Derived Attribute shown in an ER Diagram?
A Multivalued Attribute is shown by a Double Ellipse, and a Derived Attribute is shown by a Dashed Ellipse.
Tap to view answer
What is the definition of a Composite Attribute?
An attribute that can be divided into smaller independent sub-attributes (e.g., Name -> First_Name, Last_Name).
Tap to view answer
What does a Derived Attribute mean?
An attribute whose value is calculated from another attribute (e.g., calculating Age from Date of Birth).
Tap to view answer
What are the four main types of Relational Cardinality Ratios?
One-to-One (1:1), One-to-Many (1:N), Many-to-One (N:1), and Many-to-Many (M:N).
Tap to view answer
How is 'Total Participation' represented in an ER Diagram under Participation Constraints?
By a Double Line connecting the entity set and the relationship.
Tap to view answer
What are Specialization and Generalization in the ER Model?
Specialization is a Top-Down approach (splitting a broad entity into specialized sub-groups), while Generalization is a Bottom-Up approach (combining similar entities into a higher-level entity).
Tap to view answer
What type of language is Relational Algebra?
A procedural query language that specifies how to obtain the desired result.
Tap to view answer
What is the function of the 'Selection' (Οƒ) operation in Relational Algebra?
Selecting rows (Tuples) from a table that satisfy a specific condition.
Tap to view answer
What does the 'Projection' (Ο€) operation do in Relational Algebra?
Selects specific columns (Attributes) from a table and removes duplicate rows.
Tap to view answer
What is the result of a Cartesian Product (Γ—) in Relational Algebra?
If Table A has m rows and Table B has n rows, the resulting table will have m Γ— n rows and the sum of their columns (Degree_A + Degree_B).
Tap to view answer
Which condition is mandatory on tables to apply the Union (βˆͺ) operation?
Both tables must have the same degree, and corresponding columns must have matching data types (Union Compatibility).
Tap to view answer
How does 'Natural Join' (β‹ˆ) work in Relational Algebra?
It combines rows from two tables based on equal values in columns with the same name and eliminates the duplicate column.
Tap to view answer
What is the fundamental mathematical property of a Super Key?
A set of attributes in a table that uniquely identifies every tuple (row).
Tap to view answer
What is the Minimality property of a Candidate Key?
A Super Key from which if any attribute is removed, it loses its ability to uniquely identify records (a minimal Super Key).
Tap to view answer
What is the main basis for selecting a Primary Key?
The main field chosen by the database designer from the set of Candidate Keys that is unique and never Null.
Tap to view answer
When is 'Referential Integrity' established by a Foreign Key violated?
When a value is entered into the foreign key of a child table that does not exist in the primary key of the parent table.
Tap to view answer
What is the effect of the ON DELETE CASCADE clause?
When a record is deleted from the parent table, all related records in the table with the foreign key are automatically deleted.
Tap to view answer
What is the definition and use of a Surrogate Key?
An artificial primary key automatically generated by the system (such as an Auto-increment ID) that has no direct business meaning.
Tap to view answer
When is a Composite Primary Key created?
When no single attribute can uniquely identify a record, and two or more columns are combined to form a unique key.
Tap to view answer
What is the main objective of the Normalization process?
Eliminating data redundancy in database design and removing insertion, update, and deletion anomalies.
Tap to view answer
What is an Insertion Anomaly in a database?
When valid data cannot be entered as a record due to the lack or absence of other required data.
Tap to view answer
What is the adverse consequence of a Deletion Anomaly?
The unintended loss of other important related information when a single record is deleted.
Tap to view answer
Why does an Update Anomaly occur?
Due to data redundancy, when changing a value in one place fails to update all copies, creating inconsistency.
Tap to view answer
What does Functional Dependency (X -> Y) mean?
If knowing the value of X uniquely determines the value of Y, then Y is functionally dependent on X.
Tap to view answer
When is a Functional Dependency called a Trivial FD?
When the right-hand side (Y) is completely a subset of the left-hand side (X), i.e., Y βŠ† X.
Tap to view answer
What are Armstrong's Axioms used for?
To derive new valid inferences from functional dependencies (such as Reflexivity, Augmentation, and Transitivity).
Tap to view answer
What is the mandatory condition for First Normal Form (1NF)?
Each column of a table must contain only indivisible/atomic values, with no multi-valued or repeating groups.
Tap to view answer
What are the conditions to achieve Second Normal Form (2NF)?
The table must already be in 1NF and must contain no Partial Dependency.
Tap to view answer
What does Partial Dependency mean?
When a non-prime attribute depends on only a part of a composite primary key.
Tap to view answer
What is the condition for Third Normal Form (3NF)?
The table must be in 2NF and must contain no Transitive Dependency.
Tap to view answer
What does Transitive Dependency signify?
When a non-prime attribute depends on another non-prime attribute (X -> Y and Y -> Z).
Tap to view answer
Why is Boyce-Codd Normal Form (BCNF) considered a stricter form of 3NF?
Because in BCNF, for every functional dependency (X -> Y), X must mandatorily be a Super Key.
Tap to view answer
What is the main practical difference between 3NF and BCNF?
In 3NF, it is acceptable for either the left side to be a super key or the right side to be a prime attribute, whereas BCNF does not allow the exception of the right side being prime.
Tap to view answer
What type of dependency does Fourth Normal Form (4NF) eliminate?
It eliminates Multivalued Dependency (X ->-> Y).
Tap to view answer
What is Fifth Normal Form (5NF / PJNF) related to?
It eliminates Join Dependency to ensure lossless reconstruction of tables.
Tap to view answer
What does Lossless-Join Decomposition ensure?
That when a large table is split into smaller tables and rejoined via a natural join, no extra false records (Spurious Tuples) are generated.
Tap to view answer
What does Dependency Preservation mean?
The ability to verify all functional dependencies of the original table within the individual decomposed tables after splitting.
Tap to view answer
When and why is Denormalization adopted?
Intentionally introducing controlled data redundancy to avoid excessive join operations and improve query execution speed (Read Performance).
Tap to view answer
What is an Object-Relational Database Management System (ORDBMS)?
An extended form of traditional RDBMS that incorporates object-oriented concepts (such as inheritance and user-defined types) into RDBMS.
Tap to view answer
What is the primary form of data storage in a Document-Oriented Database (NoSQL)?
As self-describing documents containing key-value pairs in JSON or BSON format.
Tap to view answer
On which three principles is the CAP Theorem based?
Consistency, Availability, and Partition Tolerance.
Tap to view answer
What is the core conclusion of the CAP Theorem?
In any distributed database system, at most two of these three guarantees can be fully achieved at the same time.
Tap to view answer
What is the full form of the BASE model (in NoSQL)?
Basically Available, Soft-state, Eventual consistency (a flexible alternative to ACID).
Tap to view answer
What does Eventual Consistency mean?
That after data is updated, all nodes will eventually converge to the same consistent value over time.
Tap to view answer
What does the term 'Domain' represent in a relational database?
The set of valid, indivisible (atomic) values that can be entered into an attribute.
Tap to view answer
What is the mathematical definition of a 'Relation' in the Relational Model?
A mathematical subset of the Cartesian product of different domains.
Tap to view answer
Quick Reference
Important Facts & Contributions
Database 2
Concept / ModelKey FeatureUse / Role
Hierarchical ModelParent-child tree structure, 1:N relationship, single-parent constraintLegacy systems (e.g., IBM IMS) and file system design
Network ModelGraph structure, M:N relationship, multiple parents allowed (Owner/Member)Complex navigational databases and network systems
Relational Model (RDBMS)2D tables (Tuples/Attributes), ACID compliance, SQL supportedCore banking, e-commerce, ERP, and enterprise databases
Object-Oriented (OODBMS)Integration of data and methods as objects/classesCAD/CAM, GIS, and 3D graphics applications
NoSQL (Document/Key-Value)Schema-less, high scalability, based on the BASE modelBig Data, social media, real-time analytics
Primary KeyA distinct field with Unique and Non-Null valuesUniquely identifying each record in a table
Foreign KeyA referenced key linked to the primary key of another tableEnforcing referential integrity and establishing table relationships
Candidate KeyA minimal super key capable of becoming the primary keyPotential key options for selecting the primary key
1NF to 3NF NormalizationData atomicity, elimination of partial and transitive dependenciesPreventing data redundancy and insertion/update anomalies
ER Model (Entity-Relationship)Graphical representation of entities, attributes, and relationshipsCreating the conceptual framework of database design

One-Liner Questions

Based on which language was SQL (Structured Query Language) originally developed?
Based on SEQUEL (Structured English Query Language), developed at IBM in the 1970s.
Tap to view answer
What are the main functional categories of SQL?
DDL (Data Definition), DML (Data Manipulation), DCL (Data Control), TCL (Transaction Control), and DQL (Data Query).
Tap to view answer
What is the main function of DDL (Data Definition Language) commands?
Creating or modifying the database structure (Schema), tables, and indexes.
Tap to view answer
Which are the major DDL commands?
CREATE, ALTER, DROP, TRUNCATE, RENAME.
Tap to view answer
What is the difference between the DROP and TRUNCATE commands?
DROP completely destroys both the table structure and its data, whereas TRUNCATE removes all records while preserving the table structure.
Tap to view answer
For what purpose are DML (Data Manipulation Language) commands used?
For inserting, modifying, and deleting data within a table.
Tap to view answer
Which are the primary DML commands?
INSERT, UPDATE, DELETE (along with SELECT under DQL).
Tap to view answer
What is the difference between DELETE and TRUNCATE at the execution level?
DELETE is a DML command that can be rolled back, whereas TRUNCATE is a DDL command that executes faster and is auto-committed.
Tap to view answer
Why are DCL (Data Control Language) commands used?
To grant and revoke permissions to database users.
Tap to view answer
Which are the two main DCL commands?
GRANT (to give permissions) and REVOKE (to withdraw permissions).
Tap to view answer
Which are the major commands of TCL (Transaction Control Language)?
COMMIT, ROLLBACK, SAVEPOINT.
Tap to view answer
What is the effect of the COMMIT command in SQL?
Permanently saving all changes made by the current transaction to the database.
Tap to view answer
When and how does the ROLLBACK command work?
By undoing uncommitted changes and restoring the database to the last consistent state or a SAVEPOINT.
Tap to view answer
What is the use of the SAVEPOINT command?
Creating a temporary marker (bookmark) within a transaction to allow a partial rollback up to that point if needed.
Tap to view answer
What is the difference between the WHERE clause and the HAVING clause in SQL?
The WHERE clause applies conditions to individual rows, whereas the HAVING clause applies conditions to grouped records formed by GROUP BY.
Tap to view answer
What is the primary purpose of the GROUP BY clause?
Grouping rows that share identical values in one or more columns into summary rows.
Tap to view answer
Which are the main Aggregate Functions in SQL?
COUNT(), SUM(), AVG(), MIN(), MAX().
Tap to view answer
What do the wildcard characters '%' and '_' used with the LIKE operator in SQL mean?
'%' represents zero or more characters, while '_' represents a single character.
Tap to view answer
How does INNER JOIN work?
It returns only those records from two tables that match the join condition in both tables.
Tap to view answer
What result does LEFT OUTER JOIN return?
All records from the Left table and only the matching records from the Right table.
Tap to view answer
What is the characteristic of RIGHT OUTER JOIN?
Returning all records from the Right table and only the matching records from the Left table.
Tap to view answer
What is the result of FULL OUTER JOIN?
It returns all records from both tables, displaying Null wherever there is no match.
Tap to view answer
What is the output of CROSS JOIN (or Cartesian Join)?
All possible combinations of every row in the first table with every row in the second table (Cartesian Product).
Tap to view answer
What is called a Self Join?
When a table is joined with itself (typically by creating table aliases).
Tap to view answer
What does a Subquery or Nested Query mean?
An inner SQL query written inside a main outer SQL query.
Tap to view answer
What is a Correlated Subquery?
A subquery that depends on the values of each row from the outer query for its execution.
Tap to view answer
What is a Stored Procedure?
A group of pre-compiled SQL statements stored on the database server that can be executed repeatedly.
Tap to view answer
What is the definition of a Database Trigger?
A special type of procedure that executes automatically when a specific event (such as INSERT, UPDATE, or DELETE) occurs on a table.
Tap to view answer
Why are B-Tree and B+ Tree data structures used in an Index?
To minimize disk I/O operations when accessing data records and ensure fast searching.
Tap to view answer
What is the main difference between a Clustered Index and a Non-clustered Index?
A Clustered Index alters the physical order of data in the table (only 1 per table), whereas a Non-clustered Index creates a separate index structure.
Tap to view answer
What are the main stages of a Transaction's State Diagram?
Active -> Partially Committed -> Committed (Success) or Failed -> Aborted (Failure).
Tap to view answer
When does the Dirty Read problem occur?
When a transaction reads data modified by another uncommitted transaction that later rolls back.
Tap to view answer
What is an Unrepeatable Read?
When a data item is read twice within the same transaction and yields different results because another transaction modified its value in between.
Tap to view answer
When does a Phantom Read situation arise?
When one transaction reads a set of rows and another transaction inserts or deletes new rows in between.
Tap to view answer
What is the main objective of Concurrency Control?
Preventing database inconsistency when multiple transactions run simultaneously and maintaining Serializability.
Tap to view answer
What is a Serializable Schedule?
An interleaved execution order of concurrent transactions whose result is identical to running them sequentially one after another.
Tap to view answer
What is the rule for Exclusive Lock (X) and Shared Lock (S) in a Lock-based Protocol?
With a Shared Lock, data can only be read, whereas with an Exclusive Lock, data can be both read and written.
Tap to view answer
What are the two phases of the Two-Phase Locking (2PL) Protocol?
1. Growing Phase (only acquiring locks), 2. Shrinking Phase (only releasing locks).
Tap to view answer
What does the 2PL protocol guarantee?
It guarantees Conflict Serializability of execution.
Tap to view answer
How does Strict 2PL prevent cascading rollbacks?
By holding all exclusive locks acquired by a transaction until the transaction completely commits or aborts.
Tap to view answer
What is the definition of Deadlock in database management?
A situation where two or more transactions wait indefinitely for resources locked by each other (Circular Wait).
Tap to view answer
Which are the timestamp-based schemes for Deadlock Prevention?
The Wait-Die scheme (non-preemptive) and the Wound-Wait scheme (preemptive).
Tap to view answer
What is the use of a Wait-For Graph (WFG) in Deadlock Detection?
If a cycle forms in the WFG graph, the presence of a deadlock is confirmed.
Tap to view answer
What is the core rule of the WAL (Write-Ahead Logging) protocol?
The corresponding log record must be written to non-volatile storage (Disk) before the physical value in the database is modified.
Tap to view answer
What is the function of a 'Checkpoint' in database recovery?
Creating a point in the log file where all updated data from memory buffers has been successfully written to permanent disk.
Tap to view answer
What is the use of REDO and UNDO operations in recovery?
Committed transactions are REDOne (re-executed), and uncommitted or failed transactions are UNDOne (rolled back).
Tap to view answer
What is the Shadow Paging recovery technique?
A non-log-based recovery technique in which atomicity is maintained using a current page table and a shadow page table.
Tap to view answer
What is an SQL Injection attack?
A cybersecurity vulnerability where an attacker inserts malicious SQL code into input fields to gain unauthorized database access.
Tap to view answer
What is the primary way to prevent SQL Injection?
Using Parameterized Queries (Prepared Statements) and input sanitization.
Tap to view answer
What is the full form of TDE in Database Encryption?
Transparent Data Encryption (which automatically encrypts Data at Rest).
Tap to view answer
What is the Role-Based Access Control (RBAC) security model?
Assigning permissions to users based on their role (such as HR or Admin) rather than granting privileges directly to individuals.
Tap to view answer
How does View-based Security work in a database?
Providing users with a view of only necessary and non-sensitive columns instead of direct access to the base table.
Tap to view answer
What is the meaning and benefit of Database Replication?
Maintaining copies of the same database as replicas across different servers, providing High Availability and fault tolerance.
Tap to view answer
What is Database Sharding?
Horizontally partitioning a large database and distributing it across different physical servers (Horizontal Partitioning).
Tap to view answer
Where is the Two-Phase Commit (2PC) protocol used?
In Distributed Databases to ensure transaction atomicity across all nodes (Prepare phase and Commit phase).
Tap to view answer
What are the three main types of database backups?
Full Backup, Incremental Backup (only changes since the last backup), and Differential Backup (changes since the last full backup).
Tap to view answer
What is the capability of Point-In-Time Recovery (PITR)?
Restoring a database to the exact state it was in at any specific past time or second.
Tap to view answer
What is the function of Database Auditing?
Maintaining a security record (Audit Trail) of all activities, login attempts, and modifications in the database.
Tap to view answer
Which system accesses the Data Dictionary in an RDBMS?
The DBMS engine and Query Optimizer, to verify data access permissions and table structures.
Tap to view answer
What is Database Refactoring?
A systematic improvement made to the internal structure or design of a database without affecting its external functionality.
Tap to view answer
No matching content found.