Question

Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER...

Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables:

OWNER (OwnerID, OwnerName, OwnerEmail, OwnerType)

OWNED_PROPERTY (PropertyID, PropertyName, PropertyType, Street, City, State, Zip, OwnerID)

GG_SERVICE (ServiceID, ServiceDescription, CostPerHour);

EMPLOYEE (EmployeeID, LastName, FirstName, CellPhone, ExperienceLevel)

PROPERTY_SERVICE ( PropertyServiceID , PropertyID , ServiceID, ServiceDate , EmployeeID, HoursWorked)

The referential integrity constraints are:

OwnerID in OWNED_PROPERTY must exist in OwnerID in OWNER

PropertyID in PROPERTY_SERVICE must exist in PropertyID in OWNED_PROPERTY

ServiceID in PROPERTY_SERVICE must exist in ServiceID in GG_SERVICE

EmployeeID in PROPERTY_SERVICE must exist in EmployeeID in EMPLOYEE

Assume that OwnerID in OWNER, PropertyID in PROPERTY, and EmployeeID in EMPLOYEE are surrogate keys with values as follows:

OwnerID Start at 1 Increment by 1

PropertyID Start at 1 Increment by 1

ServiceID Start at 1 Increment by 1

EmployeeID Start at 1 Increment by 1

PropertyServiceID Start at 1 Increment by 1

Sample data are shown in Figure 3-38, Figure 3-39, Figure 3-40, Figure 3-41, and Figure 3-42. OwnerType is either Individual or Corporation. PropertyType is one of Office, Apartments, or Private Residence. ExperienceLevel is one of Unknown, Junior, Senior, Master or SuperMaster. These tables, referential integrity constraints, and data are used

Sample Data for Garden Glory OWNER Table OwnerID OwnerName OwnerEmailAddress OwnerType

1 Mary Jones [email protected] Individual

2 DT Enterprises [email protected] Corporation

3 Sam Douglas [email protected] Individual

4 UNY Enterprises [email protected] Corporation

5 Doug Samuels [email protected] Individual

Sample Data for Garden Glory OWNED_PROPERTY Table PropertyID PropertyName PropertyType Street City State ZIP OwnerID

1 Eastlake Building Office 123 Eastlake Seattle WA 98119 2

2 Elm St Apts Apartments 4 East Elm Lynwood WA 98223 1

3 Jefferson Hill Office 42 West 7th St Bellevue WA 98007 2

4 Lake View Apts Apartments 1265 32nd Avenue Redmond WA 98052 3

5 Kodak Heights Apts Apartments 65 32nd Avenue Redmond WA 98052 4

6 Jones House Private Residence 1456 48th St Bellevue WA 98007 1

7 Douglas House Private Residence 1567 51st St Bellevue WA 98007 3

8 Samuels House Private Residence 567 151st St Redmond WA 98052 5

as the basis for the SQL statements you will create in the exercises that follow. If possible, run these statements in an actual DBMS, as appropriate, to obtain your results. Name your database GARDEN_GLORY. Use data types consistent with the DBMS you are using. If you are not using an actual DBMS, consistently represent data types using either the MySQL, Microsoft SQL Server, or Oracle Database data types shown in Figure 3-5. For each SQL statement you write, show the results based on your data. Write SQL statements and answer questions for this database as follows:

B. Write foreign key constraints for the relationships in each of these tables. Make your own assumptions regarding cascading updates and deletions and justify those assumptions. (Hint: You can combine the SQL for your answers to parts A and B.)

C. Write SQL statements to insert the data into each of the five Garden Glory database tables. Assume that any surrogate key value will be supplied by the DBMS. Use the data in Figure 3-38, Figure 3-39, Figure 3-40, Figure 3-41, and Figure 3-42.

D. Write SQL statements to list all columns for all tables.

E. Write an SQL statement to list LastName, FirstName, and CellPhone for all employees having an experience level of Master.

F. Write an SQL statement to list LastName, FirstName, and CellPhone for all employees having an experience level of Master and FirstName that begins with the letter J

Will you please explain and write the instructions how to write on mySQL and thank you

FIGURE 3-40

Sample Data for Garden Glory EMPLOYEE Table EmployeeID LastName FirstName CellPhone ExperienceLevel

1 Smith Sam 206-254-1234 Master

2 Evanston John 206-254-2345 Senior

3 Murray Dale 206-254-3456 Junior

4 Murphy Jerry 585-545-8765 Master

5 Fontaine Joan 206-254-4567 Senior

FIGURE 3-41

Sample Data for Garden Glory GG_SERVICE Table ServiceID ServiceDescription CostPerHour

1 Mow Lawn 25.00

2 Plant Annuals 25.00

3 Weed Garden 30.00

4 Trim Hedge 45.00

5 Prune Small Tree 60.00

6 Trim Medium Tree 100.00

7 Trim Large Tree 125.00

FIGURE 3-42

Sample Data for Garden Glory PROPERTY_SERVICE Table PropertyServiceID PropertyID ServiceID ServiceDate EmployeeID HoursWorked

1 1 2 2019-05-05 1 4.50

2 3 2 2019-05-08 3 4.50

3 2 1 2019-05-08 2 2.75

4 6 1 2019-05-10 5 2.50

5 5 4 2019-05-12 4 7.50

6 8 1 2019-05-15 4 2.75

7 4 4 2019-05-19 1 1.00

8 7 1 2019-05-21 2 2.50

9 6 3 2019-06-03 5 2.50

10 5 7 2019-06-08 4 10.50

11 8 3 2019-06-12 4 2.75

12 4 5 2019-06-15 1 5.00

13 7 3 2019-06-19 2 4.00

Homework Answers

Answer #1

A & B: As mentioned in problem, let’s combine part A and B to create table and add foreign keys in same solution:

1. Create database and start using it: This is achieved by using below script:

Create database GARDEN_GLORY;

use GARDEN_GLORY;

2. Create tables and add referential constraints: Below is the MYSql code for table creation where a database named GARDEN_GLORY.

CREATE TABLE OWNER (OwnerID int primary key auto_increment, OwnerName varchar(50), OwnerEmail varchar(70), OwnerType Varchar(20), check (OwnerType in ('Individual' , 'Corporation')));

CREATE TABLE OWNED_PROPERTY (PropertyID int primary key auto_increment, PropertyName varchar(50), PropertyType varchar(20), Street varchar(100), City varchar(50), State varchar(5), Zip int, OwnerID int,

constraint prop_Owner foreign key(OwnerID) references OWNER(OwnerID) On Delete cascade/*no need to record properties for deleted owners*/,

check (PropertyType in ('Office', 'Apartments', 'Private Residence')));

CREATE TABLE GG_SERVICE (ServiceID int primary key auto_increment, ServiceDescription varchar(50), CostPerHour float);

CREATE TABLE EMPLOYEE (EmployeeID int primary key auto_increment, LastName varchar(50), FirstName varchar(50), CellPhone varchar(50), ExperienceLevel varchar(15), check (ExperienceLevel in ('Unknown', 'Junior', 'Senior', 'Master', 'SuperMaster')));

CREATE TABLE PROPERTY_SERVICE ( PropertyServiceID int primary key auto_increment, PropertyID int, ServiceID int, ServiceDate date, EmployeeID int, HoursWorked float,

constraint prop_services foreign key(PropertyID) references OWNED_PROPERTY(PropertyID) On Delete set null /*set null property when it is deleted from OWNED_PROPERTY to keep track of services by employee*/,

constraint given_services foreign key(ServiceID) references GG_SERVICE(ServiceID) On Delete set null /*set null when service is deleted from GG_SERVICE */,

constraint given_by foreign key(EmployeeID) references EMPLOYEE(EmployeeID) On Delete set null /*set null when employee is deleted from EMPLOYEE to keep track of services for properties */

)

C. Please find below the sql script to add records in the tables:

1. OWNER Table:

INSERT INTO OWNER (OwnerName, OwnerEmail , OwnerType) VALUES

('Mary Jones', '[email protected]','Individual'),

('DT Enterprises', '[email protected]', 'Corporation'),

('Sam Douglas','[email protected]','Individual'),

('UNY Enterprises','[email protected]','Corporation'),

('Doug Samuels','[email protected]','Individual');

Output:

2. OWNED_PROPERTY Table:

INSERT INTO OWNED_PROPERTY (PropertyName, PropertyType, Street, City, State, ZIP, OwnerID) VALUES

('Eastlake Building','Office','123 Eastlake', 'Seattle','WA', 98119, 2),

('Elm St Apts','Apartments', '4 East Elm','Lynwood', 'WA', 98223, 1),

('Jefferson Hill', 'Office','42 West 7th St','Bellevue','WA', 98007, 2),

('Lake View Apts', 'Apartments','1265 32nd Avenue','Redmond','WA', 98052, 3),

('Kodak Heights Apts','Apartments','65 32nd Avenue','Redmond','WA', 98052, 4),

('Jones House','Private Residence', '1456 48th St',' Bellevue','WA', 98007, 1),

('Douglas House', 'Private Residence', '1567 51st St','Bellevue', 'WA', 98007, 3),

('Samuels House', 'Private Residence', '567 151st St','Redmond', 'WA', 98052, 5);

OUTPUT:

3. EMPLOYEE table:

INSERT INTO EMPLOYEE(LastName, FirstName, CellPhone, ExperienceLevel)VALUES

('Smith','Sam','206-254-1234','Master'),

('Evanston','John','206-254-2345','Senior'),

('Murray','Dale','206-254-3456','Junior'),

('Murphy','Jerry','585-545-8765','Master'),

('Fontaine','Joan','206-254-4567','Senior');

OUTPUT:

4. GG_SERVICE

INSERT INTO GG_SERVICE(ServiceDescription,CostPerHour) VALUES

('Mow Lawn', 25.00),

('Plant Annuals', 25.00),

('Weed Garden', 30.00),

('Trim Hedge', 45.00),

('Prune Small Tree', 60.00),

('Trim Medium Tree', 100.00),

('Trim Large Tree', 125.00);

OUTPUT:

5. PROPERTY_SERVICE Table:

INSERT INTO PROPERTY_SERVICE (PropertyID, ServiceID, ServiceDate, EmployeeID, HoursWorked) VALUES

(1, 2,'2019-05-05',1, 4.50),

(3 ,2,'2019-05-08',3, 4.50),

(2, 1,'2019-05-08',2, 2.75),

(6 ,1,'2019-05-10',5, 2.50),

(5, 4,'2019-05-12',4, 7.50),

(8, 1,'2019-05-15',4, 2.75),

(4, 4,'2019-05-19',1, 1.00),

(7, 1,'2019-05-21',2, 2.50),

(6, 3,'2019-06-03',5, 2.50),

(5,7,'2019-06-08',4, 10.50),

(8, 3,'2019-06-12',4, 2.75),

(4, 5,'2019-06-15',1 ,5.00),

(7, 3,'2019-06-19',2, 4.00);

OUTPUT:

D. SQL statements to list all columns for all tables

Select * from OWNER;

Select * from OWNED_PROPERTY;

Select * from EMPLOYEE;

Select * from GG_SERVICE;

SELECT * from PROPERTY_SERVICE ;

OUTPUT is already inlined for each table in part C.

E: SQL to list LastName, FirstName, and CellPhone for all employees having an experience level of Master.

Query:

Select LastName, FirstName, CellPhone from EMPLOYEE where ExperienceLevel = 'Master';

OUTPUT:

F: SQL to list LastName, FirstName, and CellPhone for all employees having an experience level of Master and FirstName has J as first character

Query:

Select LastName, FirstName, CellPhone from EMPLOYEE where ExperienceLevel = 'Master' AND FirstName like 'J%';

OUTPUT:

**As it was a lengthy assignment, I tried providing complete details. Please comment if you have any doubt at line of script. Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table....
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table. SQL provides two different techniques for querying data from multiple tables: • The SQL subquery • The SQL join As you will learn, although both work with multiple tables, they are used for slightly different purposes. We used WMCRM database which is what we created in Lab 4. Here is the summary of the database schema (where schema is used in its meaning of...
Microsoft SQL Server Management Studio 1. Write SQL statements to insert, update, and delete a record...
Microsoft SQL Server Management Studio 1. Write SQL statements to insert, update, and delete a record in each of the Clients, Assist, Task, Outreach, and Specialist tables. Finish by inserting records into the tables (sample data follows). 5 points 2. Write Select statements to organize data from different tables. 4 points each Select all clients who have had an assist; include client name, assist date and type. List all assists including the name of the Specialist. List client names having...
Assignment Instructions (MY WORK IN MYSQLBENCH)- Follow instructions in class to download and build a database...
Assignment Instructions (MY WORK IN MYSQLBENCH)- Follow instructions in class to download and build a database in your DBMS. Write and demonstrate queries (in-class) that do the following: Download the appropriate attached SQL file for your DBMS. Load the file into your database design tool and run it to build the Pine Valley Furniture Company database. This is the database that is used in the textbook examples for both Chapters 5 and 6. Write a query to show the price...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a small number of records. However, the data contained within it is expected to grow significantly in the future. Creating indexes on commonly searched columns is a way performance issues can be minimized. Write a command to create an index on student_name column of the student table. Create view – 1 mark Write a command to create a view to list the student ID and...
Describe what the following query does using lyrics database with mysql. lyrics database is posted below...
Describe what the following query does using lyrics database with mysql. lyrics database is posted below 1.) select m.lastname, m.firstname, s.lastname from members m inner join salespeople s using (salesID) order by m.lastname asc; 2.) select studioID, studioname, base from salespeople sa inner join studios st on (sa.salesID = st.salesid) where base < 300 3.) SELECT artistName FROM Artists WHERE artistID IN (SELECT artistID FROM Titles) DROP TABLES IF EXISTS Artists,Genre, Members, Titles, Tracks,SalesPeople,Studios,XrefArtistsMembers; DROP TABLES IF EXISTS Authors,Publishers,Titles,Title_Authors,Royalties; DROP...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in...
Q1. Use Union statements to show the following: list the number of artists that have a...
Q1. Use Union statements to show the following: list the number of artists that have a webaddress, the number of artists that do not have a webaddress, and the total number of artists. The output should look like: +--------------------------+----------+ | Has webaddress | count(*) | +--------------------------+----------+ | Has webaddress | 5 | | Does not have webaddress | 6 | | Total | 11 | +--------------------------+----------+ Q2. A new salesperson has been hired. Their SalesID is 5, full name is...
** Note ** Execute the following query before completing steps 1 and 2: INSERT INTO Employees...
** Note ** Execute the following query before completing steps 1 and 2: INSERT INTO Employees (LastName, FirstName, BirthDate, Notes) VALUES ('Smith','Mary','1980-10-15','John is a student at Nashville State.'); 1. Using the record you just created in the Note above, write a query to update the LastName field to Jones. 2. Using the record you just created in the Note above, write a query to delete that record. 3. Write a query using the Products table that will return the sum...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT