DBMS Model Questions Overview
DBMS Model Questions Overview
Data independence refers to the capacity to modify the schema at one level of a database system without changing the schema at the next higher level. Logical data independence is the ability to change the conceptual schema without altering the existing external schemas or application programs. Physical data independence, conversely, is the ability to switch the internal schema without having to change the conceptual schema. Changes in physical storage do not affect logical structures, thus keeping applications stable despite modifications to data location, compression, etc. .
Mapping an ER diagram to a relational database model involves converting entities into tables, with entity attributes becoming table columns. Key attributes become primary keys. Relationships are translated into foreign keys, ensuring referential integrity. For one-to-one relationships, a foreign key can be assigned to either participating entity tables; for one-to-many, a foreign key is added to the 'many' side table; for many-to-many relationships, a new table is created to accommodate primary keys from both connected tables .
The three-schema architecture of a DBMS enhances data abstraction and independence by separating the database into three different levels: internal, conceptual, and external. The internal schema defines physical storage structures, the conceptual schema provides a community user view (hiding data complexity from users), and the external schemas represent user interfaces. This separation allows changes at one level to occur without altering other levels, thus supporting data independence. Logical data independence allows changes to the conceptual schema without affecting external schemas, while physical data independence refers to changes at the internal level not affecting the conceptual schema .
NoSQL databases address challenges such as large-scale data storage and high throughput demands, offering scalable storage and flexible schema designs which traditional RDBMS may struggle to manage. NoSQL is ideal for unstructured data and horizontal scaling. Types of NoSQL databases include document stores (e.g., MongoDB), key-value stores (e.g., Redis), column-family stores (e.g., Cassandra), and graph databases (e.g., Neo4j), each specializing in handling specific data formats and retrieval models optimized for speed and scaling .
Normalization from 1NF to 2NF requires eliminating partial dependency, ensuring every non-prime attribute is fully functionally dependent on the primary key. This means removing subsets of data dependent on part of a composite key. Consider a relation R with attributes {A, B, C, D}, where {A, B} is the composite primary key, and C is dependent only on A, not B. Decompose R into two relations: R1(A, C) and R2(A, B, D), removing the partial dependency C on A. R2 contains attributes fully functionally dependent on the primary key (A, B).
In relational algebra, the Union operation combines tuples from two relations (tables) that have the same arity and attribute domains. For example, if R and S are relations over the same domain, R ∪ S denotes a relation with all tuples in either or both R and S. Intersection yields tuples that are only in both relations. For example, R ∩ S results in tuples found in both R and S. Minus (also known as Difference) results in tuples present in the first relation but not in the second. For instance, R - S shows tuples in R but not in S, aiding in filtering discrepancies or exclusions .
The SQL ALTER TABLE command modifies an existing table structure. It can add or drop columns, as well as constraints. To add a constraint, use syntax like ALTER TABLE table_name ADD CONSTRAINT constraint_name constraint_type(column). To remove a constraint, use ALTER TABLE table_name DROP CONSTRAINT constraint_name. Adding constraints improves data integrity by enforcing rules at the database level, whereas removing constraints can increase flexibility but risks data inconsistency .
SQL supports several types of joins: INNER JOIN returns records with matching values in both tables; LEFT JOIN or LEFT OUTER JOIN returns all records from the left table, and matched records from the right table, returning NULL for unmatched rows; RIGHT JOIN or RIGHT OUTER JOIN is the opposite of LEFT JOIN; FULL JOIN or FULL OUTER JOIN returns records when there is a match in either left or right table records. CROSS JOIN returns the Cartesian product of two tables, meaning it joins each row from the first table with every row from the second one. These joins facilitate combined analysis of data from multiple tables .
The primary advantages of using a DBMS over traditional file systems include improved data sharing and data security, efficient data management through reduced data redundancy, data independence, and consistency, easier data access, and more robust data recovery options. DBMSs support concurrent access, ensuring multiple users can access data without conflicting, and offer complex query capabilities for rigorous data analytics .
The desirable properties of database transactions, known as ACID properties, include Atomicity, Consistency, Isolation, and Durability. Atomicity ensures transactions are all-or-nothing, Consistency maintains the database's lawful state before and after the transaction, Isolation prevents transactions from interfering with each other, and Durability guarantees completed transactions persist even amidst system failures. These properties ensure reliability, data integrity, and robust database operation critical for transaction processing .