o Answer: A relational database organizes data into tables (relations) consisting of rows and columns. Each row represents a unique record, and each column represents an attribute of the record. 2. Explain the purpose of Relational Algebra in a DBMS. o Answer: Relational Algebra provides a set of operations (such as SELECT, PROJECT, JOIN, etc.) to manipulate and retrieve data from relational databases. It forms the theoretical foundation for SQL. 3. What are the fundamental operations of Relational Algebra? o Answer: The fundamental operations include SELECT, PROJECT, UNION, SET DIFFERENCE, CARTESIAN PRODUCT, and RENAME. 4. Differentiate between Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC). o Answer: TRC uses tuples to define queries and specifies a set of tuples for retrieval, while DRC uses domain variables that take values from a specified domain to define queries. 5. What are the key components of the SQL basic structure? o Answer: The SQL basic structure includes clauses like SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY used to query and manipulate data in relational databases. 6. Explain the concept of a nested subquery in SQL. o Answer: A nested subquery is a query within another query. The result of the inner query is used by the outer query to further refine the results. 7. What is a View in SQL, and why is it used? o Answer: A View is a virtual table in SQL created by a query that combines data from one or more tables. It is used to simplify complex queries, enhance security by restricting access to certain data, and present data in a particular format. 8. Define Referential Integrity in the context of relational databases. o Answer: Referential Integrity ensures that foreign key values in one table correspond to primary key values in another, maintaining consistent and valid relationships between tables. 9. What are Aggregate Functions in SQL? o Answer: Aggregate Functions perform calculations on a set of values and return a single value. Examples include COUNT(), SUM(), AVG(), MAX(), and MIN(). 10. What is a Trigger in SQL? o Answer: A Trigger is a set of SQL statements that automatically execute or fire when certain events occur in the database, such as insertions, updates, or deletions. Long Questions
1. Describe the structure of a relational database with an example.
o Answer: A relational database is structured as a collection of tables (relations). Each table consists of rows and columns, where: Rows represent individual records or tuples. Columns represent attributes or fields. Example: Consider a "Student" table with columns: StudentID, Name, Age, Major. Rows could be: 1. 101, Alice, 20, Computer Science 2. 102, Bob, 22, Mechanical Engineering This structure allows easy retrieval and management of student data. 2. Discuss the additional and extended Relational-Algebra operations with examples. o Answer: Additional Operations: JOIN: Combines related tuples from two relations based on a common attribute. Example: Student JOIN Enrollment ON Student.StudentID = Enrollment.StudentID. INTERSECTION: Returns tuples present in both relations. Example: Students INTERSECT EnrolledInMath. Extended Operations: OUTER JOIN: Returns all tuples from both relations and fills NULLs for non-matching tuples. Types include Left, Right, and Full Outer Joins. DIVISION: Finds tuples in one relation that match all tuples in another. Example: Students enrolled in all courses offered. 3. Explain Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC) with examples. o Answer: Tuple Relational Calculus (TRC): Specifies what to retrieve without specifying how. Uses tuple variables to denote relations. Example: {T | T ∈ Student AND T.Age > 20} retrieves students older than 20. Domain Relational Calculus (DRC): Uses domain variables to specify the attributes to be retrieved. Example: {<X, Y> | ∃ Z (Student(X, Y, Z) AND Z > 20)} retrieves student names and majors where age is greater than 20. Comparison: TRC is more user-friendly and closer to SQL, while DRC provides more flexibility but can be more complex to use. 4. How do SQL Set Operations work? Illustrate with examples. o Answer: SQL Set Operations combine the results of two or more queries. Common set operations include: UNION: Combines results from two queries, removing duplicates. Example: SELECT Name FROM Students_A UNION SELECT Name FROM Students_B. INTERSECT: Returns only the rows common to both queries. Example: SELECT Name FROM Students_A INTERSECT SELECT Name FROM Students_B. EXCEPT: Returns rows from the first query that are not in the second. Example: SELECT Name FROM Students_A EXCEPT SELECT Name FROM Students_B. These operations help to merge or compare datasets from different queries effectively. 5. What are Domain Constraints and Triggers in SQL? How are they used to ensure data integrity? o Answer: Domain Constraints: These ensure that the data in a column falls within a specific range or adheres to a particular format. For example, a CHECK constraint ensures that the Age column in a Person table only contains values between 1 and 100. Triggers: These are automated procedures that execute in response to specific changes in the database. For instance, a trigger could be set to automatically update an audit table every time a record in the Orders table is modified. Use in Data Integrity: Domain constraints prevent invalid data from being entered into the database. Triggers ensure that certain actions are taken automatically to maintain consistency and integrity, such as enforcing business rules or updating related records.