Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * CSC 5 6 5 Database Management Systems Assignment 8 Intermediate SQL * / use university; # Write SQL statements for the following questions:
CSC Database Management Systems
Assignment Intermediate SQL
use university;
# Write SQL statements for the following questions:
# show all information of all instructors along with their department information join instructor and department tables Using a natural join.
# Rewrite above statement, instead of natural join, using the JOIN ON syntax.
# Rewrite above statement to show only each instructor's ID name, department, and the building of the department.
# Hint: when you use JOIN...ON syntax to join two tables, the common matching attribute from both tables will appear in the resulting table.
# Specifically the previous statement should have returned two deptname columns, one from instructor, the other from department.
# To list only one of them, you have to designate which deptname you want. either instructor.deptname or department.deptname since they always match
# Revise above statement so that your query shows only Finance instructor
# Write a statement to list department names, the building of the department, and the total credits that the students in each department have taken
# hint: join department and student, you need aggregate function, your result should look like:
# deptname building totalcredit
# Biology Watson
# Comp. Sci. Taylor
#
# Revise previous statement so that only computer science department is listed. Also instead of total credits,
# list the average credits all CS students have taken.
# Hint: When you have several keywords to use together including from, join, on where, group... you have to follow certain orders.alter
# For example, where must be after join...on and group by should appear after where.
# Using the student and takes tables,
# write an SQL query to find the ID of each student who has never taken a course at the university.
# return students who do not have a record in the takes table
# Do this using an outer join do NOT use subquery
# Create a view named "financesalary" to show the name and salary of all Finance instructor
# Note: you may not have the priviledge to actually create a view in the university database.
# Please just write down your answer without executing it
# Write a CREATE TABLE statement to make a "student" table with four attributes: ID name, dobdate of birth and height.
# Make sure to use appropriate data types and to apply the following constraints:
# ID is the primary key, name is not null, and height is a number greater than
# Note: if you want to test your statement, you would have to use your own database named by your username because you do not have CREATE priviledge
# on the university database. Or if you are confident with your answer you can write down your statement without actually creating the table.
# Based on # suppose you have successfully created a "student" table, create an index for the field "height".
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started