Question 1:
Find the details of all of reefs which have recorded a temperature-reading above 22 degrees.
Select Reef.* from Reef inner join ReefTemp on Reef.reefName = ReefTemp.reefName where temperaturereading > 22;
Find the details of all reefs which have recorded a temperature-reading below the average temperature-reading across all reefs.
Select * from Reef inner join ReefTemp on Reef.reefName = ReefTemp.reefName where temperaturereading < ( Select Avg(temperaturereading) from ReefTemp);
Find names of all reefs that do not have a sample of a coral with name including "Button”.
Select reefName from Reef inner join CoralSampling on Reef.reefName = CoralSampling.reefName inner join Coral on CoralSampling.CoralCode = Coral.CoralCode where CoralName LIKE '%Button%';
Find the coral that has the highest thermal-threshold.
Select * from Coral where thermalthreshold = (Select Max(thermalthreshold) from Coral);
Question 2 - Formulate the following queries in SQL.
Retrieve the names of corals which are in ALL reefs.
Select CoralName from Coral where CoralCode = All(Select CoralCode from CoralSampling inner join reef on CoralSampling.reefname = Reef.reefName);
List reef(s) that have at least all the corals that the reef “Wreck Is.” has.
Select Reef.reefName where Exists( Select Reef.reefName from Reef inner join CoralSampling on Reef.reefName = CoralSampling.reefName inner join Coral on CoralSampling.CoralCode = Coral.CoralCode where Reef.reefName = 'Wreck Is') ;
Do ask if any doubt. Please upvote.
Question: Question 1 - Formulate the following queries in SQL. Schema REEF [reefname, latitude, longitude, ......
- Consider the following relational schema. - Write SQL statements for the following queries employee fname CHARACTER VARYING (15) minit CHARACTER VARYING(1) InameCHARACTER VARYING(15) essn CHARACTERO) bdate DATE address CHARACTER VARYING(50) dependent works on CHARACTERO dependent name CHARACTER VARYING(15) essn CHARACTER(9) pno NUMERIC hours NUMERIC CHARACTER() DATE CHARACTER VARYING(B) bdate CHARACTER(1) dept locations elationship salary NUMERIC super ssn CHARACTERO) dno dno NUMERIC dlocation CHARACTER VARYING(15) NUMERIC department CHARACTER VARYING(25) NUMERIC CHARACTERO) project dno mgssn mgstartdate DATE pname CHARACTER VARYING(25) pno...
10- Specify the following
queries in SQL on the database schema of Figure 2. a. Retrieve the
names of all senior students majoring in ‘CS’ (Computer Science).
b. Retrieve the names of all courses taught by Professor King in
2004 and 2005. c. For each section taught by Professor King,
retrieve the course number, semester, year, and number of students
who took the section. d. Retrieve the name and transcript of each
senior student (Class =4) majoring in CS. A...
Due date: November 6, 2018 (Tuesday) Problems: 1. Specify the following queries on the database schema shown in Figure 3.6 using both the tuple relational calculus and the domain relational calculus. You don't need to show the result of each query if applied to the database of Figure 3.6. (a) Retrieve the names of employees in department 5 who work more than 10 hours per week on the 'ProductX' project (b) List the names of employees who have a dependent...
7. Using the provided schema of a Purchase Order Administration database, write the following queries in SQL. (In the schema, bold attributes are primary keys and italicized attributes are foreign keys.) SUPPLIER (SUPNR, SUPNAME, SUPADDRESS, SUPCITY, SUPSTATUS) SUPPLIES (SUPNR, PRODNR, PURCHASE_PRICE, DELIV_PERIOD) PRODUCT (PRODNR, PRODNAME, PRODTYPE, AVAILABLE_QUANTITY) PO_LINE (PONR, PRODNR, QUANTITY) PURCHASE_ORDER (PONR, PODATE, SUPNR) 7d) Write a nested SQL query to retrieve the supplier number, supplier name, and supplier status of each supplier who has a higher supplier status...
Please generate the queries in SQL given the following: Problem: Analyzing Santa’s Bike Service (20%) The Santa Bike Service provides rental bicycles in San Francisco. It distributes these bikes through several completely automated stations, each with a number of bike docks for securely parking a rental bike. Users can rent these bicycles by visiting Santa’s website, choosing their preferred station for pick-up, and paying for their rental. The website will generate a reservation code for their use. They can head...
Given the following relational schema, write queries in SQL to answer the English questions. The Access Database for the schema is available, as is a DDL file. It is also available on the MySQL server. You must only submit the SQL for your answers. You can get your answers without using a DBMS or by using Access or MySQL. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid:...
EXERCISE 1 (SQL Queries) Consider the following schema: SUPPLIERS (SID : integer, SNAME : string, CITY : string) PARTS (PID : integer, PNAME : string, COLOR : string) CATALOG (SID : integer, PID : integer, COST : real) The key fields are underlined, and the domain of each field is listed after the field name. Thus, SID is the key for SUPPLIERS, PID is the key for PARTS, and SID and PID together form the key for CATALOG. The CATALOG...
Consider a database with the following schema.BARS(name,license,city,phone,addr);BEERS(name,manf);DRINKERS(name,city,phone,addr);LIKES(drinker,beer); FREQUENTS(drinker,bar); SELLS(bar,beer,price); Return SQL code for the following queries.1. Find all distinct drinkers whose phone numbers come from area code 917 and who like Budweiser or Bud (synonim!)2. What beers does Mike like?3. Which town has the most drinkers?4. What bars are frequented by drinkers from that town (3)?5. Provide all bars which serve beers that Mike likes6. Who likes the at least one same beer that Joe or Mike like?7. All bars...
Given the following schema:
I would like to know the SQL queries to:
1. Total up the number of checkouts made on each month of the
year. Then print the month (spelled out completely) and the total
number of corresponding checkouts next to it. That is, print
"January" and total number of checkouts made in January, and so
on.
2. Show the furniture styles that are checked-out on Sundays only.
That is, none of the furniture in that style must...
I have already turned in my HW, I need some understanding of the
below SQL queries.
1. Find the number of employees in each department.
2. List the names of departments that have more than 5 employees
working there.
3. Retrieve the lowest and highest salary in each department.
Output the department name in alphabetical order.
Consider the following relational schema. An employee can work in more than on department; also, the percentTime field of the Works relations shows the...