xml and databases exercise session 3 (courtesy of ghislain fourny/eth)

Post on 31-Mar-2015

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

XML and DatabasesExercise Session 3

(courtesy of Ghislain Fourny/ETH)

Department of Computer Science

Good to know: XML Schema types

Simple type - predefined or user-defined - element or attribute type

Complex type - user-defined - element type only

Empty content Simple content Complex content Mixed content

2

Department of Computer Science

Good to know: XML Schema types

Types (can) have QNames: All predefined types

User-defined types (here simple)

3

Tags, attributes... XML Schema looks like XML... that's because it is XML!

Tags, attributes... XML Schema looks like XML... that's because it is XML!

Department of Computer Science

Good to know: XML Schema types

They can also be anonymous.

4

Anonymous types can be defined under any xs:element or xs:attribute. Non-anonymous types have a global scope and must be defined directly under xs:schema.

Anonymous types can be defined under any xs:element or xs:attribute. Non-anonymous types have a global scope and must be defined directly under xs:schema.

Department of Computer Science

Complex types in XML Schema

Complex type, complex content

5

Department of Computer Science

Complex types in XML Schema

Simple content (here anonymous)

6

Department of Computer Science

Complex types in XML Schema

Empty content Simple content restricted to "" Or a complex content without any children

Mixed content As in complex content, with an additional attribute

mixed set to true in xs:complexType

7

Department of Computer Science

Exercises 1-3

Passenger

Flight

Airport

Booking

8

Department of Computer Science

Exercises 1-3

Passenger: name, address, passport number

Flight: ID, number of seats, date, origin, dest

Airport: name, code, tax value

Booking: credit card, flight, passenger

9

Department of Computer Science

Exercise 1: XML Data

Sample data

10

Department of Computer Science

Exercise 1: XML Data

How to prevent this?

11

Department of Computer Science

Exercise 1: XML Data

How to prevent this?

With a DTD/Schema!

12

Department of Computer Science

Exercise 2: XML Schema Modelling

13

Department of Computer Science

Exercise 2: XML Schema Modelling

14

Passport number name address

Passenger

Department of Computer Science

Exercise 2: XML Schema Modelling

15

code name tax

Passport number name address

Airport

Passenger

Department of Computer Science

Exercise 2: XML Schema Modelling

16

code name tax flightID seatNo date

Passport number name address

Airport Flight

Passenger

Department of Computer Science

Exercise 2: XML Schema Modelling

17

code name tax flightID seatNo date

Passport number name address

Airport Flight

Passenger

source

dest

Department of Computer Science

Exercise 2: XML Schema Modelling

18

code name tax flightID seatNo date

credit card

Passport number name address

Airport Flight

Passenger

source

dest

book

Department of Computer Science

Exercise 2: XML Schema Modelling

19

code name tax flightID seatNo date

credit card

Passport number name address

Airport Flight

Passenger

source

dest

book

1

1

N

N

N

M

Department of Computer Science

Exercise 2: What‘s wrong?

20

Department of Computer Science

Exercise 2: Inconsistency

21

Department of Computer Science

Exercise 2: Inconsistency

22

Department of Computer Science

Exercise 2: Redundancy

23

Department of Computer Science

Exercise 2: Redundancy

24

Department of Computer Science

Exercise 2: Extraneous data

25

Department of Computer Science

Exercise 2: A Schema for Passenger

26

Passport number name address

Passenger

Department of Computer Science

Exercise 2: A Schema for Passenger

27

Passport number name address

Passenger

Department of Computer Science

Exercise 2: A Schema for Flight

28

flightID seatNo date

Airport Flight

source

dest

Department of Computer Science

Exercise 2: A Schema for Flight

29

flightID seatNo date

Airport Flight

source

dest

Department of Computer Science

Exercise 2: A Schema for Flight

30

flightID seatNo date

Airport Flight

source

dest

Department of Computer Science

Exercise 2: A Schema for Flight

31

flightID seatNo date

Airport Flight

source

dest

Department of Computer Science

Exercise 2: A Schema for Airport

32

code name tax

Airport

Department of Computer Science

Exercise 2: A Schema for Airport

33

code name tax

Airport

Department of Computer Science

Exercise 2: A Schema for Airport

34

code name tax

Airport

Department of Computer Science

Exercise 2: Root Element

35

Department of Computer Science

Exercise 3: DTD and XML Schema

36

Department of Computer Science

Exercise 3: Corresponding XML Schema

37

Department of Computer Science

Exercise 4: Corresponding XML Schema

38

Department of Computer Science

Exercise 3: Corresponding XML Schema

39

Department of Computer Science

Exercise 3: Corresponding XML Schema

40

Department of Computer Science

Exercise 3: Corresponding XML Schema

41

Department of Computer Science 42

Hope to see you next week!Hope to see you next week!

top related