Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the Schema: CREATE TABLE classroom (building varchar(15), room_number varchar(7), capacity numeric(4,0), primary key (building, room_number) ); CREATE TABLE department (dept_name varchar(20), building varchar(15), budget

image text in transcribed

Use the Schema:

CREATE TABLE classroom (building varchar(15), room_number varchar(7), capacity numeric(4,0), primary key (building, room_number) ); CREATE TABLE department (dept_name varchar(20), building varchar(15), budget numeric(12,2) check (budget > 0), primary key (dept_name) ); CREATE TABLE course (course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0) check (credits > 0), primary key (course_id), foreign key (dept_name) references department on delete set null ); CREATE TABLE instructor (ID varchar(5), name varchar(20) not null, dept_name varchar(20), salary numeric(8,2) check (salary > 29000), primary key (ID), foreign key (dept_name) references department on delete set null ); CREATE TABLE section (course_id varchar(8), sec_id varchar(8), semester varchar(6) check (semester in ('Fall', 'Winter', 'Spring', 'Summer')), year numeric(4,0) check (year > 1701 and year = 0), primary key (ID), foreign key (dept_name) references department on delete set null ); CREATE TABLE takes (ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), grade varchar(2), primary key (ID, course_id, sec_id, semester, year), foreign key (course_id,sec_id, semester, year) references section on delete cascade, foreign key (ID) references student on delete cascade ); CREATE TABLE advisor (s_ID varchar(5), i_ID varchar(5), primary key (s_ID), foreign key (i_ID) references instructor (ID) on delete set null, foreign key (s_ID) references student (ID) on delete cascade ); CREATE TABLE time_slot (time_slot_id varchar(4), day varchar(1), start_hr numeric(2) check (start_hr >= 0 and start_hr = 0 and start_min = 0 and end_hr = 0 and end_min 3. (4.5 points) (Note: Read the schema of each table in the university database from ddl.sql or using schema table-name> before working on this problem.) Write the following queries in SQL, using the university schema. (You should actually check the queries you write on the database.) (a) to find the names of all instructors whose salary is more than the 90% of the average salary of all instructors. average salary students enrolled in the section, if the section had at least 2 students. (b) to find the names of all instructors whose salary is more than the 90% of the department (c) for each course section offered in 2009, find the average total credits (tot cred) of all

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

What is meant by inheritance? Give an example.

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago