Module 4

advertisement

SD2520 Introduction to Database and XML with jQuery Unit 4

ANALYSIS 4.1 (4.0 HOURS)

Assessment Preparation Checklist:

To prepare for this assessment:

1

SD2520 Introduction to Database and XML with jQuery Unit 4

Go through Chapter 5, pp. 80–98 in the textbook, Introduction to Database and XML with

jQuery. This chapter explores the importance of database design review and normalization.

Go through this module’s lesson, which explains how to review a given ERD.

Title: Reviewing an ERD

Read the following scenario on Wild Wood Apartments and think about the requirements of the

Wildwood Apartments database:

Wild Wood Apartments owns 20 different apartment complexes in Washington, Oregon, California, and

Idaho. Each apartment complex contains anywhere from 10 to 60 separate apartments of varying sizes.

All apartments are leased with a six-month or one-year lease.

It is the company’s practice to hire one of the tenants to manage each apartment complex. As managers, they need to admit new tenants to the building, collect rent from existing tenants, and close out leases. The manager also needs to maintain the apartments and conduct any repairs, replacements, or renovations. These can be billed back to the parent company. For acting as manager, the tenant gets free rent and a stipend. The stipend varies depending on the size of the apartment building.

Each manager is expected to send a report to the Wild Wood Apartments company headquarters in San

Francisco every quarter. This report summarizes the occupancy rate, the total revenues in rent, the total expenses in maintenance and repairs, and so on. Currently managers fill out a paper form and mail it back to headquarters. Many apartment managers have complained that preparing this report is a very difficult and time-consuming process. In addition, the managers at the corporate headquarters have expressed concern about the accuracy and verifiability of the reports.

To allay these concerns and to improve the ease and efficiency with which the apartment managers conduct their daily business, the company is proposing the development of a centralized database that the managers can use to track the daily business of their apartment building and to prepare their reports.

As a follow-up on your initial interview with the project coordinator, Wild Wood Apartments has agreed to show you some samples of the various forms and reports they use.

Design a database that is normalized to 3NF to guard against various types of anomalies.

Create a Visio file that shows the normalized database design and in a Microsoft Word document, explain the rationale for making your design. Describe how your design protects against insertion, deletion, and update anomalies.

Submission Requirements:

For this analysis, you need to submit the following files to your instructor: o The Word document titled “SD2520_Module 4_Analysis 4_1.docx” o The Visio file that shows the normalized design

Evaluation Criteria:

The analysis rubric will be used to evaluate this assessment. In addition, your submission will be evaluated against the following points:

Did you normalize your design to the first normal form?

Did you normalize your design to the second normal form?

2

SD2520 Introduction to Database and XML with jQuery Unit 4

Did you normalize your design to the third normal form?

Did you document the reason for each change, the normalization form that required it, and the anomaly it protects against?

LAB 4.1 (3.0 HOURS)

Assessment Preparation Checklist:

To prepare for this assessment:

Go through Chapter 5, pp. 80–98 in the textbook, Introduction to Database and XML with

jQuery. This chapter describes the importance of design review and normalization and examines how to evaluate an entity against the first three normal forms.

Go through this module’s lesson, which describes the process of normalizing an ERD.

Title: Normalizing an ERD

In this lab, you will review a given ERD and normalize it using Microsoft Visio.

Required Setup and Resources:

Windows XP (or later)

Microsoft Visio 2003 (or later)

Lab4_1starter.vsd

Recommended Procedure:

1.

Read the Westlake hospital scenario given below:

The start of the double-blind test is approaching rapidly. There is a great deal of pressure on you to begin building the actual database. Before you can do that, though, you must perform a final review to make sure that the database is normalized and complete.

2.

Launch Microsoft Visio on your lab computer. Note that Visio is installed on the host operating system, not on your virtual machine.

3.

Open Lab4_1starter.vsd. This file shows one table in the database design for the Westlake

Research Hospital scenario.

4.

Save Lab4_1starter.vsd as nnLab4_1solution.vsd, where nn are your initials.

5.

Normalize the PatientVisit table to the first normal form by referring to the Patient Visit form given below:

3

SD2520 Introduction to Database and XML with jQuery Unit 4

Notice that there are a number of predefined symptoms with checkboxes, as well as a field where the doctor can write symptoms that are not listed. This means that the Symptoms attribute might contain an array of values and violate the first normal form. One way to handle this would be to create a separate attribute for each symptom listed, but that still wouldn’t handle the possibility that the patient might have other symptoms. Therefore, a better solution is to create a separate entity named PatientVisitSymptoms. Next, perform the following steps: a.

Add an entity named PatientVisitSymptoms to the ERD. b.

Define the following attributes:

4

SD2520 Introduction to Database and XML with jQuery Unit 4 i.

PatientKey (PK) ii.

VisitDate (PK) iii.

Symptom c.

Add a relation that creates a one-to-many relationship between PatientVisit and

PatientVisitSymptoms. d.

Remove the Symptoms attribute from the PatientVisit entity.

Now, look at the DoctorNotes attribute. This attribute is one you would want to discuss with the client. If a doctor needs to enter multiple notes, it would be a good idea to normalize using a similar approach as for the Symptoms table. However, if a doctor’s note should be treated as a single field, you would want to leave it as is.

6.

Normalize the PatientVisit entity to normal form 2.

Can you see any functional dependencies in the entity? (HINT: In what circumstance would the

DropReason attribute not contain a value?) Next, perform the following steps: a.

Add a DroppedPatient entity that includes the following attributes to your ERD: i.

PatientKey ii.

DateDropped iii.

ReasonDropped b.

Add a one-to-one relationship between the DroppedPatient table and the Patient table. c.

Remove the ContinueOrDrop and DropReason attributes from the Patient Visit table.

7.

Normalize the PatientVisit entity to normal form 3.Are there attributes that do not relate to the primary key? What about DoctorName?

Remember, each patient is assigned a doctor, which is identified by DoctorKey in the Patients entity. Therefore, DoctorName is dependent on only PART of the primary key, not on the full primary key. Remove the DoctorName attribute from the PatientVisit entity.

Your normalized table should look like this:

5

SD2520 Introduction to Database and XML with jQuery Unit 4

Submission Requirements:

Submit the Visio file titled “nnLab4_1solution.vsd” to your instructor for grading.

Evaluation Criteria:

The lab rubric will be used to evaluate this assessment. In addition, your submission will be evaluated against the following points:

Did you create all the required tables?

Did you define all the required keys?

Did you define all the required relationships?

LAB 4.2 (3.0 HOURS)

Assessment Preparation Checklist:

To prepare for this assessment:

Go through Chapter 6, pp. 100–119 the textbook, Introduction to Database and XML with

jQuery. This chapter examines the implementation of the physical design of the database based on logical ERDs.

Go through this module’s lesson, which describes the different database management systems with a special focus on MySQL.

Title: Creating a Database

In this lab, you will first explore the fields in MySQL and then create a database for Westlake hospital.

Required Setup and Resources:

Windows XP (or later)

Microsoft Visio 2003 (or later)

MySQL Workbench 5.2 CE

Recommended Procedure:

Note: For the steps that require you to paste the screen shot or answer a question, document your response in a Microsoft Word worksheet titled “SD2520_Module 4_Lab4_2.docx”. Make sure to assign a corresponding task number against each response or screen shot.

Task 1: Exploring Tables, Rows, Columns, and Relationships

1.

Launch ITT-Lab.

2.

Click Start> My Programs> MySQL> MySQL Workbench 5.2 CE.

6

SD2520 Introduction to Database and XML with jQuery

3.

Double-click LocalInstance MySQL55.

Unit 4

4.

When prompted for a password, type the root password. On the ITT-Lab virtual machine, it is

P@$$word.

5.

Select Save password in vault and click OK.

6.

7.

Expand World.

Expand Tables.

7

SD2520 Introduction to Database and XML with jQuery Unit 4

8.

Explore the World database.

Question 1: Which tables are included in the World database?

____________________________________________________________________________

Question 2: Which column should be the Primary Key for the city table?

____________________________________________________________________________

Question 3: Which column is most likely a foreign key column in the city table?

____________________________________________________________________________

Question 4: Which table and column does the foreign key reference?

____________________________________________________________________________

Question 5: What type of relationship exists between the country table and the city table?

____________________________________________________________________________

Question 6: Which column of the countrylanguage table is most likely a foreign key?

____________________________________________________________________________

9.

Close the Query Editor tab.

10.

Click Create EER Model From Existing Database.

11.

Click Next> Next.

8

SD2520 Introduction to Database and XML with jQuery Unit 4

12.

Check world and click Next> Next.

13.

Click Execute> Next> Finish.

14.

Drag the tables so that they can all be seen. Take a screen shot and paste it in your worksheet.

Question 7: What type of relationship exists between countries and languages?

____________________________________________________________________________

Question 8: What type of primary key is used in the countrylanguage table?

____________________________________________________________________________

Question 9: Which key is the primary key of the country table?

____________________________________________________________________________

15.

Click the bottom 1:n relationship icon.

16.

Click country.

17.

Click city and then click country.

18.

Add a one-to-many relationship between the countrylanguage and country tables.

Question 10: How can the composite key support the many-to-many relationship between the entities?

____________________________________________________________________________

Question 11: What is another way to implement a many-to-many relationship?

____________________________________________________________________________

19.

Take a screen shot and paste it in your worksheet.

20.

Close the EER Model diagram tab.

21.

Close the MySQL Model tab.

22.

When you are prompted to save, click Save.

23.

Save the file as nnMod4Lab2a.mwb.

Task 2: Creating the Westlake Hospital Database

1.

Read the following Westlake Research Hospital scenario:

The drug study is falling into place. Several potential participants have already been interviewed.

It is vital that the database be in place soon. You assure the management that you are ready to begin making the database objects but that it is essential you test and evaluate the objects

9

SD2520 Introduction to Database and XML with jQuery Unit 4 before they start to commit data to it. You promise that you will deliver the database as soon as possible.

In this lab, you will be implementing the portion of the Westlake Research Hospital database shown in the following ERD:

2.

In MySQL Workbench, click New EER Model.

3.

Double-click Add Table.

4.

Name the table Patients.

5.

In the Columns pane, define the FirstName, MiddleName, LastName, and PhoneNumber columns as shown below:

10

SD2520 Introduction to Database and XML with jQuery Unit 4

6.

Close the Table pane.

7.

Add a table named Doctors, which includes the DoctorKey and DoctorName columns.

8.

Create a DroppedPatients table, which includes the PatientKey, DateDropped, and

ReasonDropped columns.

9.

Create a Groups table that includes the GroupKey and GroupDescription columns.

11

SD2520 Introduction to Database and XML with jQuery Unit 4

10.

Double-click Add Diagram.

11.

Drag each table to the canvas.

12.

Use the Place a relationship using existing columns icon to create a one-to-many relationship between Patients and DroppedPatients.

13.

Right-click the relationship and choose Edit Relationship.

14.

Click Foreign Key.

15.

Change the relationship type to one-to-one.

16.

Close the relationship tab.

17.

Double-click the DroppedPatients table.

18.

Click Foreign Keys and configure the relationship as shown:

12

SD2520 Introduction to Database and XML with jQuery Unit 4

19.

Use the 1:n icon shown here to create a relationship between the Doctors table and the

Patients table.

Question 12: What was added to the Patients table?

___________________________________________________________________________

13

SD2520 Introduction to Database and XML with jQuery Unit 4

20.

Double-click the Patients table and remove the check from PK for the DoctorKey column.

21.

Close the table editor.

22.

Add a many-to-many relationship between the Groups table and the Patients table.

Question 13: What was created?

___________________________________________________________________________

23.

Take a screen shot and paste it on your worksheet.

24.

Click File> Save Model As.

25.

Name the file nnMod4Lab2.mwb.

26.

Click Database> Forward Engineer.

27.

Keep the default connection settings and click Next.

28.

Do not select any options. Click Next.

29.

Keep the default options and click Next.

30.

Review the generated script. Click Next.

14

SD2520 Introduction to Database and XML with jQuery Unit 4

31.

If the generation completes successfully, you should see this message; otherwise, correct any problems and repeat steps 26 through 30.

32.

On the Home tab, click Edit Table Data.

33.

Keep the connection settings and click Next.

34.

Select mydb from the Schema drop-down list.

35.

Verify that all five tables appear in the Tables list.

36.

Select the doctors table and click Finish.

37.

Enter the following data:

38.

Click Apply.

39.

When prompted to confirm the Insert statements, click Apply.

40.

Click Finish.

41.

Right-click Patients and choose Edit Table Data.

15

SD2520 Introduction to Database and XML with jQuery

42.

Enter the data shown below:

Unit 4

43.

Click Apply> Apply> Finish.

44.

Enter the following data in the groups table.

45.

Click Apply> Apply> Finish.

46.

Enter the following data in the patients_has_groups table:

47.

Click Apply> Apply>Finish.

48.

Enter the following data in the droppedpatients table:

49.

Click Apply> Apply> Finish.

50.

Right-click doctors and choose Select Rows - Limit 1000. Take a screen shot of your results and paste it on the worksheet.

51.

Repeat step 50 for each of the other tables.

Submission Requirements:

For this lab, you need to submit the following files to your instructor: o The Word document titled “SD2520_Module 4_Lab4_2.docx”

16

SD2520 Introduction to Database and XML with jQuery Unit 4 o The MySQL file titled “nnMod4Lab2a.mwb” o The MySQL file titled “nnMod4Lab2b.mwb”

Evaluation Criteria:

The lab rubric will be used to evaluate this assessment. In addition, your submission will be evaluated against the following points:

Did you include all the screen shots in the Word document?

Did you answer all questions in the Word document?

QUIZ 2 (1.0 HOUR)

Assessment Preparation Checklist:

To prepare for the quiz, revisit the assigned readings for Modules 3 and 4 from your textbook

Introduction to Database and XML with jQuery. In addition, review and attempt the practice questions given in the topic “Preparation” in the lessons for Modules 3 and 4.

Title: Quiz 2 – A PowerPoint review will be given before week 6.

On Week 6: Take the quiz based on the concepts covered in Modules 3 and 4.

17

Download