Stanford DTD Assignment
This is the first week of the free on line db classes of Stanford University. It is a great opportunity for all of us that have learned some time ago the dbs to revise and learn the up to dated info about the db technology, from the best of the world. I have tried the video lectures and the assignments of the first week. For me the most difficult assignments were the DTD XML Files.
You should try to solve them by yourself, so as to gain experience and learn in depth the DTDs.
I publish my solution so that we can discuss and comment only. Try the exercises by yourself. The joy will be tremendous.
DTD SOLUTION EXERCISE 1
<!ELEMENT Course_Catalog (Department*)>
<!ELEMENT Department (Title, Chair, Course+)>
<!ATTLIST Department Code CDATA #REQUIRED>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Chair (Professor)>
<!ELEMENT Professor (First_Name,Middle_Initial?,Last_Name)>
<!ELEMENT First_Name (#PCDATA)>
<!ELEMENT Last_Name (#PCDATA)>
<!ELEMENT Middle_Initial (#PCDATA)>
<!ELEMENT Course (Title,Description?,Instructors,Prerequisites?)>
<!ATTLIST Course Number CDATA #REQUIRED Enrollment CDATA #IMPLIED>
<!ELEMENT Description (#PCDATA)>
<!ELEMENT Instructors (Lecturer | Professor)*>
<!ELEMENT Lecturer (First_Name,Middle_Initial?,Last_Name)>
<!ELEMENT Prerequisites (Prereq+)>
<!ELEMENT Prereq (#PCDATA)>
DTD SOLUTION EXERCISE 2
<!ELEMENT Course_Catalog (Department*)>
<!ELEMENT Department (Title, Course+,(Professor+,Lecturer*)*)>
<!ATTLIST Department Code CDATA #REQUIRED Chair IDREF #REQUIRED>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Course (Title,Description?)>
<!ATTLIST Course Number ID #REQUIRED Instructors IDREFS #IMPLIED Prerequisites IDREFS #IMPLIED Enrollment CDATA #IMPLIED>
<!ELEMENT Description (#PCDATA | Courseref)*>
<!ELEMENT Courseref EMPTY>
<!ATTLIST Courseref Number IDREF #REQUIRED>
<!ELEMENT Professor (First_Name,Middle_Initial?,Last_Name)>
<!ATTLIST Professor InstrID ID #REQUIRED>
<!ATTLIST Lecturer InstrID ID #REQUIRED>
<!ELEMENT First_Name (#PCDATA)>
<!ELEMENT Last_Name (#PCDATA)>
<!ELEMENT Middle_Initial (#PCDATA)>
<!ELEMENT Lecturer (First_Name,Middle_Initial?,Last_Name)>
DTD SOLUTION EXERCISE 3
<!ELEMENT countries (country*)>
<!ELEMENT country (language | city)*>
<!ATTLIST country name CDATA #REQUIRED population CDATA #REQUIRED area CDATA #REQUIRED>
<!ELEMENT language (#PCDATA)>
<!ATTLIST language percentage CDATA #REQUIRED>
<!ELEMENT city (name,population)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT population (#PCDATA)>
Σχόλια
Good post.
It help everybody.
My name is marcio Im from Brazil.
thank you!