Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- HAFH (Home Away from Home) Realty Company leases apartments to corporate clients. HAfH flealty Company Property Management Database will keep track of HAFH buildings,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
- HAFH ("Home Away from Home") Realty Company leases apartments to corporate clients. HAfH flealty Company Property Management Database will keep track of HAFH buildings, apartments, corporate clients, building managers, cleaning staff members, and building inspectors. The property management database for the realty company HAFH will capture data about the following: - For each building: Building1D (unique) and BNoOffloors (number of floors in the building); - For each apartment: AptNo (partially unique, Le., unique within a building) and ANoOf Bedrooms (number of bedrooms in the apartment); - For each corporate client: CCID (unique), CCName (unique), CClocation, and CCindustry; - For each manager: ManageriD (unique), MFullName (composed of MFirstName and MLastName), multiple MPhone numbers, MBDate, MAge (derived from MBdate and current date), MSalary, and MBonus (not every manager will have a bonus): - For each staff member: SMemberlD (unique) and SMemberName; - For each inspector: insID (unique) and InsName; - Each building has one or more apartments, Each apartment is located in exactly one building. - Each apartment is either leased to one corporate client or to no one. Each corporate client leases between zero and many apartments. - Each corporate client refers between zero and many corporate clients. Each corporate client can be referred by one corporate client or is not. referred by any. - Each apartment is cleaned by either one or two staff members. Each staff member cleans between five and ten apartments. - Each manager manages one or many buildings. Each building is managed by exactly one managef. - Each manager resides in exactly one building. Each building either has one manager residing in it or no managers residing in it. - Each inspector inspects one or many buildings. Each building is inspected by one or many inspectors. - For each building that a particular inspector inspects, the dates of the last inspection by the inspector and of the next future inspection by the inspector are recorded." Write SQL queries (i.e., SELECT.. FROM... etc.) to solve the following problems for the HAFH ("Home Away from Home") Realty Company using the schema for the HAFH ("Home Away from Home") Realty Company database on the next page. You only need to provide the SQL SELECT... FROM... statements, properly numbered using comments. You do NOT need to provide the results of the SQL SELECT.. FROM.. statements. 1. Display all attributes for all records in the INSPECTS table, sorted by the date of the next inspection. 2. Display the inspector ID, inspector name, building ID, and date of next inspection for all inspectors who have any inspections scheduled after April 1st, 2020 of buildings with more than three floors, sorted by inspector name, building ID, and date of next inspection. 3. Display the name of the corporate client and the name of the corporate client who referred it, for every corporate client referred by a corporate client in the Music industry, sorted by the corporate client name. In the output, the column headers should be "Client Name" and "Referred By". 4. Display the staff member ID and staff member name of staff members cleaning apartments rented by corporate clients whose corporate location is Chicago, sorted by staff member name. Do not display the same staff member more than once. 5. Display the first and last names, current salaries, salaries after a 20% raise, and phone numbers of each manager who resides in a building that he or she also manages whose current salary is between $50,000 and $60,000 (use the keyword BETWEEN). and whose last name either begins with S or ends with T, ordered by their last name, first name, and phone number. When displaying salaries in the output, use column headers Current_Salary and New_Salary. (Note that MPhone attribute is in a table called MANAGERPHONE.) 6. Display the building ID, apartment number, and employee (staffmember or inspector) name of apartments that are either cleaned by a staffmember employee whose name begins with C or are located in a building inspected by an inspector employee whose name begins with B, ordered by the employee name, building ID, and apartment number. The column header for the employee name should be Employee_Name. Use the UNION keyword in your solution. Schema for the HAFH ("Home Away from Home") Realty Company. INSPECTOR table Attributes: InsID InsName Primary key (InsID) BUILDING table Attributes: BuildingID BNoOfFloors ManagerlD Primary key (BuildingID) Foreign key (ManagerID) references MANAGER(ManagerID), Relationship: Manages, NOT NULL, ON DELETE RESTRICT CORPCLIENT table Attributes: CCID CCname CClndustry CCLocation CCIDreferredby Primary key (CCID) Unique key(CCname) Foreign key (CCIDreferredby) references CORPCLIENT(CCID) , Relationship: Refers, NULL, ON DELETE RESTRICT MANAGER table Attributes: ManagerID Bdate MFirstName MlastName Mbonus Msalary BuildingID Primary key (ManagerlD) Foreign key (BuildingID) references BUILDING(BuildingID), Relationship: Residesin, NOT NULL, ON DELETE RESTRICT STAFFMEMBER table Attributes: SMemberID SMemberName Primary key (SMemberID) APARTMENT table Attributes: BuildingID AptNo AnoOfBedrooms CCID Primary key (BuildingID, AptNo) Foreign key (BuildingID) references BUILDING(BuildingID) , Relationship: Locatedln, NOT NULL, ON DELETE CASCADE Foreign key (CCID) references CORPCLIENT(CCID) , Relationship: Leases, NULL, ON DELETE RESTRICT INSPECTS table Attributes: InsiD BuildingID DateLast DateNext Primary key (InsID, BuildingID) Foreign key (InsID) references INSPECTOR(InsID) , Relationship: Inspects, NOT NULL, ON DELETE CASCADE Foreign key (BuildingID) references BUILDING(BuildingID), Relationship: Inspects, NOT NULL, ON DELETE CASCADE CLEANS table Attributes: BuildingID AptNo SMemberID Primary key (BuildingID, AptNo, SMemberID) Foreign key (BuildingID, AptNo) references APARTMENT(BuildingID, AptNo), Relationship: Cleans, NOT NULL, ON DELETE CASCADE Foreign key (SMemberID) references STAFFMEMEBER(SMemberID), Relationship: Cleans, NOT NULL, ON DELETE CASCADE MANAGERPHONE table Attributes: ManagerID Mphone Primary key(ManagerID, Mphone) Foreign key(ManagerID) references MANAGER (ManagerID), NOT NULL, ON DELETE CASCADE

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

Step: 3

blur-text-image

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago