You are on page 1of 6

Assignment: DBMS

Vivek Kumar,
B. Tech (IT and MI),
Roll no. 12058,
3rd semester

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.
Q2.

Table:- Employee
fname mname lname ssn badate sex address salary sssn Dno
(f-ssn) (f-dnumber)

Table: - Department
dname dnumber mgrssn Mgrstart date
(f-ssn)

Table: - Dept_location
dnumber(f-dnumber) dlocation

Table: - Project
pname pnumber plocation dnum
Table: - Works_on
esssn(f-ssn) pno hrs

Table: - Dependent
essn dapendentnam sex bdate rel
e

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 2: Count no. of employee in each dept in form of dname and count.
Answer 2: SELECT dname , count(fname)
From Employee as emp, Works_on as wks, Department as dept
Where emp.sssn=wks=.essn
And emp.ssn=depndt.essn
And wks. hrs>10

Query 3: Display employee names who are working more than 10 hrs.
Answer 3: SELECT fname, name,lname
From Employee as emp, Dependent as depndt, Works_on as wrks
Where emp.ssn=depndt.essn
And wrk.hrs>10

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 5: All the project no. of the department which is managed by "smith".
Answer 5: SELECT pnumber
From Employee as emp, Department as dept, Project as prjt, Works_on as
wrks
Where emp.sssn=dept.mgrssn
And wrks.pno=prjt.pnumber
And wrks.essn=emp.sssn
And emp.fname= “%smith”

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 wrks.pno=prjt.pnumber
And wrks.essn=emp.sssn
And emp.fname= “%smith”
And dept.dname in ( “worker”, “manager”)

Query 7: Name an employee who has more than 2 departments.


Answer 7: SELECT fname, mname, lname
From Employee as emp, Department as dept
Where emp.sssn=dept.mgrssn
And count(emp.dno)>2

Q3. A database is being constructed to keep track of the teams and games of a sports
league. A team has a number of players, not all of whom participate in each game. It is
desired to keep track of the players participating in each game for each team, the
positions they played in that game, and the result of the game. Design an ER schema
diagram for this application, stating any assumptions you make. Choose your favorite
sport (e.g., soccer, baseball, football).
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.

You might also like