Presentation is loading. Please wait.

Presentation is loading. Please wait.

RELATIONAL DATABASES AND XML

Similar presentations


Presentation on theme: "RELATIONAL DATABASES AND XML"— Presentation transcript:

1 RELATIONAL DATABASES AND XML
12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 1

2 Objectives Compare the following data storage technologies:
Describe a relational database. Describe XML. Write a program that accesses data from a relational database. Design relational database tables. Use Structured Query Language (SQL) Access a database from Visual Basic .NET Access a database using Java Database Connectivity (JDBC) Write a program that accesses data from an XML file. Create an XML document. Identify the .NET XML classes 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 2

3 Tables and Relationships
12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 3

4 One-To-One Relationships
Almost always expressed as an attribute of a table. Customer 1 FirstName 1 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 4

5 One-To-Many Relationships
A table has 0, 1, or many related records Usually expressed through a foreign key relationship Primary key is on the “one” side of the relationship. Order1 FK Order2 Customer FK PK Customer3 FK 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 5

6 Many-to-Many Relationships
12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 6

7 Data Access Classes for Bound Controls
SqlConnection Defines connection SqlDataAdapter Retrieves data from the database DataSet Stores the data DataGrid Bound control 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 7

8 Data Bound Controls 12/3/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 9 Slide 8

9 Updating Data 12/3/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 9 Slide 9

10 Deleting Records 12/3/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 9 Slide 10

11 Validating Data 12/3/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 9 Slide 11

12 SELECT results SELECT FirstName, LastName FROM tblCustomer
12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 12

13 SELECT with Where Clause
SELECT FirstName, LastName, City, State FROM tblCustomer WHERE State = 'CO' OR State = 'CA' 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 13

14 SELECT with BETWEEN SELECT * FROM tblOrder
WHERE OrderDate BETWEEN '1/4/2001' an '6/5/2001' 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 14

15 SELECT With LIKE SELECT * FROM tblCustomer WHERE FirstName LIKE 'J%'
Wildcard characters * ? % _ [a-m]% 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 15

16 SELECT With IN SELECT FirstName, LastName, State FROM tblCustomer
WHERE State IN ('CO','WI') 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 16

17 ORDER BY SELECT * FROM tblOrder ORDER BY OrderDate Desc SELECT TOP 3 *
12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 17

18 JOINS SELECT FirstName, LastName, OrderDate FROM tblOrder
INNER JOIN tblCustomer ON tblOrder.CustomerID = tblCustomer.ID 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 18

19 Data Returned by Join 12/3/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 9 Slide 19

20 Aggregates SELECT tblOrder.CustomerID, FirstName, LastName, COUNT(dbo.tblOrder.CustomerID) AS TotalOrders FROM tblOrder INNER JOIN tblCustomer ON tblOrder.CustomerID = tblCustomer.ID GROUP BY FirstName, LastName, CustomerID 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 20

21 Results of Previous Query
12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 21

22 HAVING SELECT tblOrder.CustomerID, FirstName, LastName, COUNT(dbo.tblOrder.CustomerID) AS TotalOrders FROM tblOrder INNER JOIN tblCustomer ON tblOrder.CustomerID = tblCustomer.ID GROUP BY FirstName, LastName, CustomerID HAVING (COUNT(tblOrder.CustomerID) > 1 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 22

23 Aggregate Functions 12/3/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 9 Slide 23

24 UPDATE UPDATE tblItem SET Price = Price * 1.1 UPATE tblInventory
WHERE RetailPrice > 100 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 24

25 DELETE DELETE * FROM tblOrder WHERE OrderDate < '10/31/98'
12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 25

26 INSERT INSERT INTO tblOrder (CustomerID, OrderDate)
VALUES (119, '6/16/2001') INSERT INTO tblOrderArchive SELECT * FROM tblOrder WHERE OrderDate < #6/1/2001# 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 26

27 XML Element with Subelements
<Person firstName="John" lastName="Doe" address1="123 Main Street" address2 = "' '" city="Sometown" state="OH"   zip="22222" phone=" ">             <orders>                         <order id="111"                                     itemid="2923"                                     itemdesc="Super Foo Widget">                         </order>             </orders> </Person> 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 27

28 XML/XSL Hierarchy 12/3/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 9 Slide 28

29 XML and XSL Example 12/3/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 9 Slide 29

30 XML Classes in VB.NET xmlNode xmlNodeList xmlDocument
12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 30

31 Summary In this unit the students learned to:
Compare the following data storage technologies: Describe a relational database. Describe XML. Write a program that accesses data from a relational database. Design relational database tables. Use Structured Query Language (SQL) Access a database from Visual Basic .NET Access a database using Java Database Connectivity (JDBC) Write a program that accesses data from an XML file. Create an XML document. Identify the .NET XML classes 12/3/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 9 Slide 31


Download ppt "RELATIONAL DATABASES AND XML"

Similar presentations


Ads by Google