QUESTION 5
Suppose there are two tables: A and B. and we run command SELECT * from A LEFT JOIN B on A.orderid = B.orderid. What would be the code output?
|
only the records from table A where tables A and B have the same orderid |
||
|
only the records from table B where tables A and B have the same orderid |
||
|
the complete set of records from table A, along with the matching records (depending on the availability) from table B where tables A and B have the same orderid |
||
|
the complete set of records from table B, along with the matching records (depending on the availability) from table A where tables A and B have the same orderid |
10 points
QUESTION 6
Suppose there are two tables: A and B and we run command SELECT * from A INNER JOIN B on A.orderid = B.orderid. What would be the code output? ;
|
only the records from table A where tables A and B have the same orderid |
||
|
only the records from both tables A and B where tables A and B have the same orderid |
||
|
the complete set of records from table A, along with the matching records (depending on the availability) from table B where tables A and B have the same orderid |
||
|
the complete set of records from table B, along with the matching records (depending on the availability) from table A where tables A and B have the same orderid |
10 points
QUESTION 7
What is the function COUNT() used for?
|
to return the number of tables in a database. |
||
|
To return the number of SQL statements in query |
||
|
To return the number of columns that match a specified criteria |
||
|
To return the number of rows that match a specified criteria |
10 points
QUESTION 8
Which of the following is not a type of join?
|
LEFT JOIN |
||
|
FULLER INNER JOIN |
||
|
INNER JOIN |
||
|
FULL OUTER JOIN |
10 points
QUESTION 9
What is the purpose for having a relational database management system?
|
To extract and manipulate big data |
||
|
To store data tables that relate to one another through keys |
||
|
To access data more quickly |
||
|
To share data across platforms |
10 points
QUESTION 10
Which of the following does a relational database not contain?
|
Tables |
||
|
Queries |
||
|
ID Graphs |
||
|
Indices |
10 points
QUESTION 11
Microsoft Access can help beginners learn SQL because it...
|
offers more SQL functionality than other SQL tools |
||
|
generates SQL code from visual representations of queries |
||
|
offers a video tutorial on creating strong SQL commands |
||
|
integrates well with Microsoft Excel to create advanced SQL statements |
10 points
QUESTION 12
When was SQL developed by IBM?
|
1950s |
||
|
1960s |
||
|
1970s |
||
|
1980s |
10 points
QUESTION 13
Which of the following includes matched records from the right table and all records from the left table?
|
INNER JOIN |
||
|
LEFT JOIN |
||
|
RIGHT JOIN |
||
|
FULL JOIN |
10 points
QUESTION 14
Which of the following is using records that have matching values in both tables?
|
INNER JOIN |
||
|
LEFT JOIN |
||
|
RIGHT JOIN |
||
|
FULL JOIN |
10 points
QUESTION 15
If we run this query SELECT departmentid, MAX(salary) FROM employees group by departmentid. What will the query show?
|
The maximum salary for every department |
||
|
The maximum salary for every employee, organized by department |
||
|
The department id that has the highest salary across all the departments |
||
|
The employee that has the highest salary within each department |
10 points
QUESTION 16
Which join uses records that have matching values in both tables?
|
Inner join |
||
|
Left join |
||
|
Right join |
||
|
Full join |
10 points
QUESTION 17
Which join uses records whether or not there are matching values in both tables?
|
Inner join |
||
|
Left join |
||
|
Right join |
||
|
Full join |
10 points
QUESTION 18
Which of the following is correct?
|
Select EmployeeName From Employees Where 1234 |
||
|
Select EmployeeName Where ID = 1234 From Employees |
||
|
Select EmployeeName From Employees Where ID = 1234 |
||
|
Select Employees.EmployeeName Where ID = 1234 |
Q5). C
Q6). B
Q7). D
Q8). B
Q9). B
Q10). C
Q11). B
Q12). C
Q13). B
Q14). A
Q15). A
Q16). A
Q17). D
Q18). C
QUESTION 5 Suppose there are two tables: A and B. and we run command SELECT *...
Which SQL statement retrieves the EmployeeName and City columns from the Employees table? O LIST EmployeeName, City ON Employees; O FIND EmployeeName, City ON Employees; SELECT EmployeeName, City FROM Employees; O RETRIEVE EmployeeName, City FROM Employees; Which SQL statement finds the different cities in which national parks reside with no duplicate rows listed? SELECT DISTINCT city FROM natlpark ORDER BY city; O ORDER BY natlpark DISTINCT city; O ORDER BY city FROM natlpark; O SELECT city FROM natlpark ORDER BY...
A(n) __________________ is a logical connection between rows in two tables where data in one table references data in another table. The SQL ________________ statement removes a table from a database. The relational algebra "restrict" operator selects only the rows from the input table(s) that satisfy a condition expressed in the _________________ clause. The SQL/PL ______________ command is used to re-direct the output of a script file to a text file. The ________________________ join creates a result set that includes the...
Question 9 (1 point) Saved 9. What type of JOIN returns all rows from the left table and any matching rows from the right table? a. FULL OUTER JOIN b. LEFT OUTER JOIN OC. RIGHT OUTER JOIN Od. INNER JOIN Question 10 (1 point) 10. What type of JOIN returns all rows from the right table and any matching rows from the left table? a. FULL OUTER JOIN Ob. LEFT OUTER JOIN C. RIGHT OUTER JOIN Od. INNER JOIN
BONUS QUESTION: Suppose you have two tables, EMPLOYEES with primary key employee_ID, and DEPARTMENTS with primary key department_ID. Assume each department may have many employees, but each employee is only assigned one department. What would be the correct SQL syntax for retrieving data from both tables? (HINT: You must find out what is the foreign key) A. SELECT employee_ID, employee_name, department_ID, department_location FROM Employees JOIN Departments ON Employees.employee_ID = Departments.employee_ID; B. SELECT employee_ID, employee_name, department_ID, department_location FROM Employees JOIN Departments...
QUESTION 21 Complete the table below by matching each definition with the appropriate SQL clause. -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A mandatory clause that is at the start of all SQL retrieval queries -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause used to return only the values in a result table that are unique -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause used to filter tuples according to some condition or predicate, like selection in relational algebra -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause that is used to list the tables and any joins required in a query...
QUERY EXAMPLE2 SELECTfrom Employee em (Refer to query example 2 to answer questions 12- 13) 12. You plan to join the Location table and fear there may be some employees with no location. You want to make sure that the query returns a list of all employee What join clause would you add to the query above? records. A. LEFT JOIN Location lo ON em.LocationlD lo LocationID B. RIGHT JOIN Location lo ON em.LocationID lo.LocationlD C. INNER JOIN Location lo...
Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary keys are underlined and foreign keys are preceded with #): Customer (customerID,customerFirstName,customerLastName,customerAddress) Oreder (orderID,orderDate, #customerID,#menuItemID,#staffID) MenuItem(menuItemID, menuItemName,ingredients,type,availability) Staff(staffID, staffName, staffPhoneNumber, staffRole ) OrderPayment(paymentID,paymentAmount,#orderID,#staffID) 1) Without using DISTINCT, write the SQL query equivalent to the following one:[1.5 marks] SELECT DISTINCT menuItemName FROM MenuItem WHERE type = ‘Vegetarian’ OR availability= ‘Yes’; 2) Express the following queries in SQL: a) Find the number of orders placed by...
Task1: Construct and run the code for a natural
inner join on the two tables
AccountState and AccountUserState
Task 2: Construct and run the code for a
natural inner join of
AccountState, AccountUserState, ClientProperty
Task 3: Construct and run the code for
Right outer join on ClientProperty and
AccountUserState
Task 4: Construct and run the code to sum the
account totals for each branch.
Construct your own database for this and enter the data.
AccountNr, BranchNr, ClientNr...
Create the database and tables
for the database. Show all SQL statements. Include primary and
foreign keys. Insert data into each table. Show select statements
and display the output of each table. Note:Student’s name must be
inserted into table as part of the data! Perform the SQL below:
Query one table and use WHERE to filter the results. The SELECT
clause should have a column list, not an asterisk (*). State the
purpose of the query; show the query and...
A query that is based on more than two tables and
includes both an arithmetic and a special operator in the
conditional expression. Both the arithmetic and the special
operator must be different from the ones used in part
a
PART A.
Select Car_Cust.Cust_Num, Car_Model from Car_Cust inner join Car
on Car_Cust.Car_VIN = Car.Car_VIN inner join Car_Type on
Car.Car_Code = Car_Type.Car_Code where Car_Code = 'C123' and
Car_Model IN('M1','M2','M3',M7');
I keep getting an error message ...
PART B . Need help...