0% found this document useful (0 votes)
46 views1 page

SQL and Relational Algebra Queries Guide

I. This document discusses SQL queries and relational algebra concepts related to a student-book-issue database schema. II. It asks the reader to write SQL queries to list students by branch, books by publisher, issued books by student with title and author, and books issued before a date. III. It also provides an overview of SQL and relational algebra operations like selection, projection, join and their uses in querying relational databases.

Uploaded by

Ayush Thakur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views1 page

SQL and Relational Algebra Queries Guide

I. This document discusses SQL queries and relational algebra concepts related to a student-book-issue database schema. II. It asks the reader to write SQL queries to list students by branch, books by publisher, issued books by student with title and author, and books issued before a date. III. It also provides an overview of SQL and relational algebra operations like selection, projection, join and their uses in querying relational databases.

Uploaded by

Ayush Thakur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment II

Q Student (RollNo, Name, Father_ Name, Branch)


Book (ISBN, Title, Author, Publisher)
Issue (RollNo, ISBN, Date-of Issue)
Write the following queries in SQL and relational algebra:
I. List roll number and name of all students of the branch
II.
publisher.
III. List title of all books and their authors issued to a student
IV. List title of all books issued on or before December 1, 2020.
V. List all books published by publisher
Q Introduce SQL (Structured Query Language). What are the characteristics of SQL that make it a popular
language for working with relational databases?

Q What is Aggregate Function in SQL? Write SQL query for different Aggregate Function.

Q Consider the following relational DATABASE. Give an expression in SQL foreach following
queries Underline records are Primary Key
Employee( person_name , street , city)
Works(person_name, Company_name ,salary)
Company(Company_name , city)
Manages( person_name, manager_name)
i). Finds the names of all employees who works for the ABC bank
ii). Finds the name of all employees who live in the same city and on thesame
street as do their managers
iii). Find the name street address and cities of residence of all employees who
work for ABC bank and earn more than 10,000 per annum
iv). Find the name of all employee who earn more than every employee of XYZ
v). Give all Employees of corporation ABC a 10% salary raise
vi). Delete all tuples in the works relation for employees of ABC
vii). Find the name of all employees in this DATABASE who live in the same
city as the company for which they work
Q Provide an overview of the key operations in Relational Algebra. How do selection, projection,
union, and join operations work in the context of relational databases?
Q Explore SQL joins and their various types (e.g., INNER JOIN, LEFT JOIN, RIGHT JOIN). When and
why would you use each type of join in SQL queries?

Q Describe axioms in detail. What is the role of these rules indatabase development
process?
Q What is Functional Dependency? Explain the procedure of calculating the Canonical Cover of a given
Functional Dependency Set with suitable example.

Q What is the purpose of Normalization? Explain 1NF, 2NF, 3NF and BCNF with suitable example? 19

Submit before 16th December, 2023

Common questions

Powered by AI

Axioms in database development are foundational rules used to infer all possible functional dependencies from a given set. Their significance lies in ensuring a complete and consistent design for relational databases. They provide a framework for understanding how data attributes depend on each other, which is critical for normalization and schema optimization. A well-applied set of axioms helps define precisely how data should be structured and accessed, improving integrity and query performance .

To give all ABC employees a 10% raise, you'd update the salary column: UPDATE Works SET salary = salary * 1.10 WHERE Company_name='ABC'. This SQL UPDATE statement selects employees at ABC and increases their salary by multiplying it by 1.10, efficiently applying the raise across relevant records .

Normalization is essential in database design to reduce redundancy and improve data integrity. 1NF requires that a database table conforms to the atomicity of data, no repeating groups; 2NF requires that it first be in 1NF and that all non-key attributes are fully functional dependent on the primary key. 3NF goes further, ensuring no transitive dependencies on non-prime attributes. BCNF (Boyce-Codd Normal Form) is a stricter version of 3NF where every determinant is a candidate key. Each level reduces redundancy and dependency to a different degree, enhancing data integrity and reducing anomalies .

The JOIN operation in SQL is used to combine rows from two or more tables based on a related column. A RIGHT JOIN returns all rows from the right table, and the matched rows from the left table; non-matching rows in the left table result in NULL on the related tables. This join is useful when retrieving all records from the right table and any matches from the left table are desired, such as when you need a complete list of employees and any orders they might have placed, ensuring no employee is left out regardless of having placed an order .

Selection (σ) filters rows based on specific criteria, projection (π) chooses specific columns, union (U) merges tuples from two relations excluding duplicates, and join (⨝) combines related tuples from two relations. These operations allow for complex query formulation, facilitating data retrieval, manipulation, and organization across tables. Each operation addresses different query requirements, enabling users to filter, combine, and process data in a flexible manner .

In relational algebra, the query is expressed as follows: π_person_name,city(σ_Company_name='ABC bank'(Works ⨝ Employee)). This uses the selection operation σ to filter employees working for ABC bank, the projection operation π to select the required columns, and the join operation ⨝ to combine the Works and Employee relations based on person_name .

Calculating the Canonical Cover involves minimizing a set of functional dependencies so that it is equivalent to the original, but more efficient for normalization. The process includes eliminating extraneous attributes and redundant dependencies, then decomposing the original dependencies into a minimal set. It's important because it simplifies database design and ensures the integrity and consistency of the data by focusing only on the necessary attributes and dependencies, reducing redundancy .

To find employees earning more than any at XYZ, you would use a subquery as follows: SELECT person_name FROM Works WHERE salary > ALL (SELECT salary FROM Works WHERE Company_name='XYZ'). The subquery calculates the list of salaries at XYZ, and the main query checks for larger salaries .

SQL is popular for relational databases due to its declarative nature, enabling users to specify what they want to achieve without dictating how to do it. It includes robust support for complex queries and data manipulation, consistency, and integrity constraints. It is standardized widely used in the industry, and supports both Data Definition Language (DDL) and Data Manipulation Language (DML). Its intuitive syntax allows for easy data retrieval, updates, and schema management, making it accessible for both simple to complex applications .

Aggregate functions summarize data across multiple rows. Examples include COUNT, which gives the number of entries, used as SELECT COUNT(*) FROM table; SUM, which adds up values, used as SELECT SUM(salary) FROM employees; AVG, computing the average, used as SELECT AVG(salary) FROM employees; MAX, finding the largest value, as SELECT MAX(salary) FROM employees; and MIN for the smallest value, as SELECT MIN(salary) FROM employees. These functions allow for quick insights into data sets .

You might also like