Questions Based on SQL – Part 6 Question 1 : Consider the following relations: Student(snum: integer, sname: string, major: string, level: string, age: integer) Class(name: string, meets at: string, room: string, fid: integer) Enrolled(snum: integer, cname: string) Faculty(fid: integer, fname: string, deptid: integer) The meaning of these relations is straightforward; for example, Enrolled has one…

QUESTIONS SQL – Part 3 Question 1 : The following relations keep track of airline flight information: Flights(flno: integer, from: string, to: string, distance: integer, departs: time, arrives: time, price: real) Aircraft(aid: integer, aname: string, cruisingrange: integer) Certified(eid: integer, aid: integer) Employees(eid: integer, ename: string, salary: integer) Note that the Employees relation describes pilots and other…

SQL Questions – Part 2 Question 1 : You are given the following relational schema: Person(PersonID, Name, Sex, CityOfBirth) Parent(ParentID, ChildID) ParentID and ChildID are foreign keys referring to Person.PersonID. Write the following queries in SQL: (a) Find the names of grandparents of all the people who were born in San Francisco. Solution : SELECT p2.PersonID,…

Queries on SQL Operators QUERIES : Example of Some Queries related to aggregate functions Consider the relation Student(Rollno, Name, Age, Marks1, Marks2, Marks). Following Results are obtained from the Queries below : Result 1: MAX and MIN marks can be used on both numeric and non numeric columns. For Example, SELECT MAX(Marks) FROM Student; √ SELECT MAX(Name)…

Questions on SQL Question 1 : Consider the following schema: Suppliers(sid: integer, sname: string, address: string) Parts(pid: integer, pname: string, color: string) Catalog(sid: integer, pid: integer, cost: real) The Catalog relation lists the prices charged for parts by Suppliers. Write the following queries in SQL: 1. Find the pnames of parts for which there is…

The CREATE VIEW Command Views are the logical Windows for users to see the results of operations on one or more base tables or views. A view is a virtual table, just like a table which is in a 2 dimensional structure of rows and columns. These are derived from stored data structures and computed again…