Professional Documents
Culture Documents
Q1. What is the use of SQL and Non-SQL databases? When to use which one?
Specify with scenarios?
A1. The preference among SQL and NoSQL relies upon completely on character situations as
each of them has blessings in addition to disadvantages. SQL databases are long-set up with a
hard and fast schema layout and a fixed structure. They are perfect for packages that require
multi-row transactions which include an accounting machine or for legacy structures that had
been constructed for a relational structure.
On the opposite hand, NoSQL databases are effortlessly scalable, flexible, and easy to apply
as they haven't any inflexible schema. They are perfect for packages without unique schema
definitions which include content material control structures, huge statistics packages, real-
time analytics, etc.
SQL is the finest database to employ for relational data, notably when the link among data sets is
easily understandable and accessible. It’s also the greatest way to check for data security and
integrity. SQL enables rising ad-hoc queries, and, in most circumstances, SQL databases are
vertically expandable if you require flexibility in data access.
Use Cases SQL-
• SQL is the simplest language used for interacting with a relational database management
system.
• Understanding and modifying behavioural-related programs
• Creating unique dashboards
Query 1: For every project located in “Safford” list pno, compolting dno, dept
manager name.
Answer 1: - SELECT pno, dno, fname
From Employee as emp, Department as dept, Project as prjt, Works_on as
wrks
Where emp.sssn=mgrssn
And emp.sssn=wks=.essn
And emp.ssn=dept.essn
And prjt.plocation= “%Safford”
Query 4: Select query to find out project no. that involve an employee with the
name “SMITH” as worker.
Answer 4: SELECT pnumber
From Employee as emp, Project as prjt, Works_on as wrks
Where emp.fname= “%smith”
And wrks.pno=prjt.pnumber
And wrks.essn=emp.sssn
Query 6: List of all project no. Where employe smith working both as worker
and manager.
Answer 6: SELECT pnumber
From Employee as emp, Department as dept, Project as prjt, Works_on as
wrks
Where emp.sssn=dept.mgrssn
And dept.dname in ( “worker”, “manager”)
A3.
Q4. Consider the relation R, which has attributes that hold
schedules of courses and sections at a university; R = {Course_no,
Sec_no, Offering_dept, Credit_hours, Course_level, Instructor_ssn,
Semester, Year, Days_hours, Room_no, No_of_students}.
Suppose that the following functional dependencies hold on R: {Course_no} →
{Offering_dept, Credit_hours, Course_level} {Course_no, Sec_no, Semester, Year} →
{Days_hours, Room_no, No_of_students, Instructor_ssn} {Room_no, Days_hours,
Semester, Year} → {Instructor_ssn, Course_no, Sec_no}.
Try to determine which sets of attributes form keys of R. How would you normalize this
relation?
A4.