Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Exercise 01:

Consider the following relational database Commodity:

  Products:

pid Name Price Description


323 gizmo 22.99 great
233 gizmo plus 99.99 more features
312 gadget 59.99 good value
Stores:
sid Name Phone
s282 Wiz 555-1234
s521 Econo-Wiz 555-6543
Sells:
pid Sell sid
323 10% s521
233 25% s282
233 15% s521

We want to export this data into an XML file. Write a DTD describing the
following structure for the XML file:

- There is one root element called stores


- The stores element contains a sequence of store sub elements, one for
each store in the database

- Each store element contains one name, and one phone as attributes,
and a sequence of product subelements, one for each product that the
store sells. Also, it has an attribute sid of type ID.

- Each product element contains one name, one price, one description, and one
sell element, plus an attribute pid of type CDATA.

Exercise 02:

Create DTD for XML documents below:

<bank>
<account account-number=“A-101” branch-name=“Downtown” balance=“500”>
</account>
<account account-number=“A-102” branch-name=“Perryridge” balance=“400”>
</account>
<account account-number=“A-201” branch-name=“Brighton” balance=“900”>
</account>
<customer customer-name=“Johnson” customer-street=“Alma” customer-city=“Palo
Alto”>
</customer>
<customer customer-name=“Hayes” customer-street=“Main” customer-city=“Harrison”>
</customer>
<depositor account-number=“A-101” customer-name=“Johnson”></depositor>
<depositor account-number=“A-201” customer-name=“Johnson”></depositor>
<depositor account-number=“A-102” customer-name=“Hayes”></depositor>
</bank>

Exercise 03:

Create XML document for follow DTD:


<!DOCTYPE emp [
<!ELEMENT emp (ename, children*, skills*)>
<!ELEMENT children (name, birthday)>
<!ELEMENT birthday (day, month, year)>
<!ELEMENT skills (type, exams+)>
<!ELEMENT exams (year, city)>
<!ELEMENT ename( #PCDATA )>
<!ELEMENT name( #PCDATA )>
<!ELEMENT day( #PCDATA )>
<!ELEMENT month( #PCDATA )>
<!ELEMENT year( #PCDATA )>
<!ELEMENT type( #PCDATA )>
<!ELEMENT city( #PCDATA )>
]>

Exercise 04:

Create DTD for XML documents below:

<?xml version="1.0" encoding="UTF-8"?>


<parts>
<part>
<name>bicycle</name>
<subpartinfo>
<part>
<name>wheel</name>
<subpartinfo>
<part>
<name>rim</name>
</part>
<qty>1</qty>
</subpartinfo>
<subpartinfo>
<part>
<name>spokes</name>
</part>
<qty>40</qty>
</subpartinfo>
<subpartinfo>
<part>
<name>tire</name>
</part>
<qty>1</qty>
</subpartinfo>
</part>
<qty>2</qty>
</subpartinfo>
<subpartinfo>
<part>
<name>brake</name>
</part>
<qty>2</qty>
</subpartinfo>
<subpartinfo>
<part>
<name>gear</name>
</part>
<qty>3</qty>
</subpartinfo>
<subpartinfo>
<part>
<name>frame</name>
</part>
<qty>1</qty>
</subpartinfo>
</part>
</parts>

You might also like