Module 5

advertisement
SD2520
Introduction to Database and XML with jQuery
Unit 5
ANALYSIS 5.1 (4.0 HOURS)
Assessment Preparation Checklist:
To prepare for this assessment:
1
SD2520


Introduction to Database and XML with jQuery
Unit 5
Go through Chapter 7, pp. 123–149 in the textbook, Introduction to Database and XML with
jQuery. This chapter explores how to run queries using a database management system for a
given set of business rules.
Go through this module’s lesson, which describes how data retrieval queries are run in MySQL.
Title: Writing Data Retrieval Queries
The managers of Wild Wood Apartments are eager to see the database in action and see if it meets all
their needs and requirements. It is time to look at the business rules and test them with some SQL.
Imagine that you need to design some SQL queries to test the business rules.
In a Microsoft Word document, complete the following tasks:


Enter some sample data for each table in the database design. Make up at least 10 records for
each table.
Write a query to return all columns for each table.

Write a query to return selected columns for each table.

Write a query to return all columns for each table in ascending order by primary key.

Write a query to return all columns for each table in descending order by primary key.

Write some queries with two or three simple SELECTs with various criteria.

Write two queries using aggregate functions.

Write two queries using the GROUP BY and HAVING keywords.

Write two queries that use Inner joins.

Write two queries that use Left Outer joins.

Write two queries that use Right Outer joins.

Write two INSERT statements.

Write two UPDATE statements.

Write two DELETE statements.
Submission Requirements:
Submit a Microsoft Word document showing the list of queries and the requested database records with
following specifications:
 Font: Arial; font size: 12; double-spaced
 Length: 2–3 pages
Evaluation Criteria: This assignment will be evaluated using the analysis rubric. In addition, your
submission will be evaluated against the following points:
 Did you make up a minimum of 10 records for each table?
 Did you write all the queries correctly?
 Did you design SQL queries based on the given scenario?
2
SD2520
Introduction to Database and XML with jQuery
Unit 5
LAB 5.1 (4.0 HOURS)
Assessment Preparation Checklist:
To prepare for this assessment:
 Go through Chapter 7, pp. 123–149 in the textbook, Introduction to Database and XML with
jQuery. This chapter explores how to run queries using a database management system for a
given set of business rules.
 Go through this module’s lesson, which describes how queries are run in MySQL.
Title: Working with SQL Queries
In this lab, you will design and run SQL queries for the given set of business rules.
Required Setup and Resources:
 Windows XP (or later)
 MySQL
Recommended Procedure:
Note: For the steps that require you to paste screen shots or answer a question, document your
response in a Microsoft Word worksheet titled “SD2520_Module 5_Lab5_1.docx”. Make sure to assign a
corresponding task number against each response or screen shot.
Task 1: Executing SELECT Queries
1. Launch ITT-Lab.
2. Launch MySQL Workbench.
3. Double-click Local Instance MySQL55.
4. If prompted, type the root password and click OK.
5. Select mydb.
6. Type the following query and then click Execute.
Question 1: How many rows were returned?
___________________________________________________________
Question 2: How many columns were returned?
__________________________________________________________
7. Type and execute a query that returns all rows and columns of the Patients table.
3
SD2520
Introduction to Database and XML with jQuery
Unit 5
Question 3: What query did you execute?
_____________________________________________________________
8. Execute a query that returns only the FirstName, LastName, and PhoneNumber columns of the
Patients table.
Question 4: What query did you execute?
_____________________________________________________________
9. Execute a query that returns the LastName of only the patients that have a DoctorKey column
of 123.
Question 5: What query did you execute?
_____________________________________________________________
10. Execute the following query:
SELECT Count(*) FROM Patients WHERE DoctorKey = 123
Question 6: What did this query tell you?
_____________________________________________________________
11. Execute the following query:
SELECT * FROM Patients
WHERE MiddleName IS NULL OR FirstName = 'George'
You can use IS NULL and IS NOT NULL to check whether a column that allows null contains a
value or null.
Task 2: Executing DML Statements
1. Execute the following query:
INSERT INTO Patients
(PatientKey, DoctorKey, FirstName, MiddleName, LastName,
PhoneNumber)VALUES ('2-3','22222','Susan',NULL,'Michaels','555-4444')
2. Execute a SELECT statement to verify that the record exists. Take a screen shot and paste it on
your worksheet.
3. Execute a query that assigns Susan Michaels to the Experimental group.
Question 7: What query did you execute?
_____________________________________________________________
4. Execute the following statement:
UPDATE Patients
SET DoctorKey = 123
WHERE PatientKey = 2
5. Execute a query that assigns all patients currently assigned to Dr. Jones to Dr. Thomas.
4
SD2520
Introduction to Database and XML with jQuery
Unit 5
Question 8: Which query did you execute?
_____________________________________________________________
Question 9: How many rows were affected?
_____________________________________________________________
Task 3: Executing Queries that Perform Joins
1. Execute the following query:
SELECT FirstName, LastName, DoctorName AS Doctor
FROM Patients
JOIN Doctors ON Patients.doctors_DoctorKey = Doctors.DoctorKey
2. Take a screen shot of the results and paste it on your worksheet.
3. Execute the following query:
SELECT FirstName, LastName, DoctorName AS Doctor
FROM Patients
RIGHT JOIN Doctors ON Patients.doctors_DoctorKey = Doctors.DoctorKey
4. Take a screen shot and paste it on your worksheet.
Question 10: How did the results differ from the query you ran in step 1? Explain why.
_____________________________________________________________
5. Execute the following query:
SELECT FirstName, LastName, DoctorName AS Doctor
FROM Patients
RIGHT JOIN Doctors ON Patients.doctors_DoctorKey = Doctors.DoctorKey
JOIN patients_has_groups ON Patients_PatientKey =
Patients.PatientKey
WHERE Groups_GroupKey=1
6. Take a screen shot and paste it in your worksheet.
7. Execute the following statement:
SELECT Doctors.DoctorName, COUNT(*)
FROM Patients
RIGHT JOIN Doctors ON Patients.doctors_DoctorKey = Doctors.DoctorKey
JOIN patients_has_groups ON Patients_PatientKey =
Patients.PatientKey
GROUP BY Doctors.DoctorName
8. Take a screen shot and paste it on your worksheet.
5
SD2520
Introduction to Database and XML with jQuery
Unit 5
Submission Requirements:

For this lab, you need to submit the Microsoft Word document titled “SD2520_Module 5_Lab51.docx” to your instructor.
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 successfully execute the SELECT statements?

Did you successfully execute the DML statements?

Did you successfully execute joins?

Did you include all the screen shots in the Word document?

Did you answer all questions in the Word document?
LAB 5.2 (3.0 HOURS)
Assessment Preparation Checklist:
To prepare for this assessment:


Go through Chapter 15, pp. 254–268 in the textbook, Introduction to Database and XML with
jQuery. This chapter will give you a firm grasp of the basics of jQuery and the tools that will
make working with jQuery straightforward.
Go through this module’s lesson, which explores the basics of jQuery and how it works with the
Document Object Model (DOM).
Title: Using jQuery
In this lab, you will use jQuery to interact with the Document Object Model (DOM).
Required Setup and Resources:

Windows XP (or later)

HTML-Kit 292 (or other HTML editor)

jquery-1.5.min.js (downloaded during lab)

Internet Explorer (or any other web browser)

Mod5Lab2pics.zip
Recommended Procedure:
6
SD2520
Introduction to Database and XML with jQuery
Unit 5
Note: For the steps that require you to paste screen shots or answer a question, document your
response in a Microsoft Word worksheet titled “SD2520_Module 5_Lab5_2.docx”. Make sure to assign a
corresponding task number against each response or screen shot.
Task 1: Downloading jQuery (WE ALREADY HAVE IT IN LAB 7)
1. Create a folder named SD2520Mod5Lab2 in the My Documents folder on ITT-Lab.
2. Change the Virtual Machine Networking option to Bridged, if necessary.
3. Open a Web browser.
4. Navigate to http://jquery.com/download/.
5. Right-click the link to download the uncompressed version of jQuery 1.x.
6. Choose Save Link As.
7. Save the file to the folder you created in Step 1.
8. Close the browser.
9. If you set the Networking mode to bridged, change it back to Host-only.
Task 2: Download and install HTML-Kit
1. Check whether HTML-Kit is installed on ITT-Lab. If it is not, download and install it using the
following steps.
2. Change the Networking mode of ITT-Lab to Bridged.
3. Open a web browser.
4. Navigate to htmlkit.com.
5. Click Get Previous Version (free).
7
SD2520
Introduction to Database and XML with jQuery
Unit 5
6. Click Download HTML-Kit 292.
7. After it downloads, launch HKSetup.exe.
8. Click Run > Next.
9. Select I accept the agreement and click Next.
10. Click Next.
11. Choose Full installation (the default) and click Next.
8
SD2520
Introduction to Database and XML with jQuery
Unit 5
12. Click Next to accept the default folder.
13. Click Next > Install.
14. Uncheck Yes, download and install HTML-Kit Tools Trial.
15. Click Next > Finish.
16. Change your virtual machine Networking settings to Host-only mode.
Task 2: Creating a Simple jQuery Application
1. Launch HTML-Kit.
2. Create a new HTML file and save it as nnMod5Lab2.htm.
3. Add the following HTML to the file:
<!DOCTYPE HTML>
<html>
<head>
<title>Hello World - jQuery Style</title>
</head>
<body>
<div id="first"></div>
<div id="second"></div>
<a href="#" id="link">Click Me!</a><br />
9
SD2520
Introduction to Database and XML with jQuery
Unit 5
<span id="greeting"></span>
</body>
</html>
4. Add the following <script> element to the <head> section. NOTE: Use the jQuery version
number that matches the file name of the file you downloaded in Step 1.
<script type="text/javascript" src="jquery-1.11.0.js"></script>
5. Add the following <script> element beneath the one you added in Step 4:
<script type="text/javascript">
$(document).ready(function() {
/*write 'Hello World! to the first div */
$('#first').html('<h1> Hello World!</h1>');
});
</script>
6. Preview in the browser window to verify that “Hello World”!” displays. TIP: You might need to
enable scripts to run on your browser.
7. Take a screen shot and paste it on your worksheet.
8. Add the following function beneath the selector you wrote in step 5:
/*a clickable 'Hello World!' example */
$('#link').click(function(){
$('#greeting').html('<h1>Hello Again!</h1>');
});
9. Test to verify that “Hello Again” displays when you click the link.
10. Take a screen shot and paste it on your worksheet.
Task 3: Navigating a List
1. Copy Mod5Lab2pics.zip to your virtual machine and extract the .jpg files to the folder you
created in Task 1.
2. Add the following HTML beneath the HTML you added in Task 2:
<div>
<h1>Pictures</h1>
<ul>
<li><a class="pic" href="#"><img src="brass.jpg" /></a></li>
<li><a class="pic" href="#"><img src="sunburst.jpg" /></a></li>
<li><a class="pic" href="#"><img src="ice.jpg" /></a></li>
<li><a class="pic" href="#"><img src="horizon.jpg" /></a></li>
10
SD2520
Introduction to Database and XML with jQuery
Unit 5
</ul>
<div id="showCurrentPicName">
</div>
<div id="showNextPicName"> </div>
</div>
3. Preview in a browser to verify it looks like this.
4. Take a screen shot and paste it on your worksheet.
5. Add the following jQuery function:
/*Output the filename of the clicked picture*/
$('.pic').click(function(e) {
var currentImage = $(this)
.closest('li')
.find('img')
.attr('src');
$('#showCurrentPicName').html('<h1>You clicked ' + currentImage +
'</h1>');
});
6. Test your code and take a screen shot of the results of clicking each picture.
11
SD2520
Introduction to Database and XML with jQuery
Unit 5
7. Modify your code to output the filename of the graphic below the one clicked. TIP: Clicking the
bottom graphic should output “Undefined”.
8. Test your code and take a screen shot of the results of clicking each picture.
Question: In this example, the anchors have no href. If they did, how would you prevent
navigation to the new content?
__________________________________________________________________________
9. Zip the folder you created in Task 2, and turn it in along with your worksheet.
Submission Requirements:

For this lab, you need to submit the following files to your instructor:
o
Microsoft Word document titled “SD2520_Module 5_Lab5_2.docx”
o
A .zip file containing nnMod5Lab2.htm (where nn are your initials), the starter images,
the latest jQuery 1.x.js file.
Evaluation Criteria:
The lab rubric will be used to evaluate this assessment. In addition, your submission will be evaluated
against the following points:
 Were you able to create a jQuery script that executed when the document loaded?

Were you able to create a jQuery script that executes when a user clicks a link?

Were you able to create a jQuery script that navigated elements in the DOM?

Did you include all the screen shots in the Word document?
RESEARCH 5.1 (3.0 HOURS)
Assessment Preparation Checklist:
To prepare for this assessment:
 Revisit Chapter 6, pp. 100–119 in the textbook, Introduction to Database and XML with jQuery.
This chapter covers the physical design implementation of a database using Microsoft SQL
Server.
 Go through this module’s lesson, which explores the different database management systems
(DBMs).
Title: Comparing DBMSs
Using the ITT Tech Virtual Library and the Internet, explore and research the latest versions of the
following database management systems (DBMSs) on the market: Oracle, Microsoft SQL Server, MySQL,
and SQLite.
Use the following keywords and phrases to begin your research: “Database Management Systems,
Compare different DBMS systems, Oracle, Microsoft SQL Server, MySQL, SQLite.”
12
SD2520
Introduction to Database and XML with jQuery
Unit 5
Based on your research, compare the four DBMSs on different parameters. Make sure to include the
pros and cons associated with each DBMS. You can use the following comparison table format to
document your answer:
Oracle
MySQL
SQLite
Microsoft SQL Server
Operating
Systems
Supported
DML
Statement
Syntax
(CREATE,
ALTER, and
DROP)
DDL syntax
(INSERT,
UPDATE,
DELETE,
JOIN,
Aggregates)
Stored
Procedure
Syntax
(CREATE)
Latest Stable
Version and
Year of
Release
Advantages
Disadvantages
13
SD2520
Introduction to Database and XML with jQuery
Unit 5
Submission Requirements:
Submit a Microsoft Word document with following specifications:

Font: Arial; font size: 12; double-spaced

Length: 1–2 pages

Citation Style: APA
Evaluation Criteria:
This assignment will be evaluated using the research assignment rubric.
14
Download