0
2.6kviews
Give the DTD for the XML schema

Subject: Distributed Database

Topic: XML

Difficulty: High


Consider a library database system ,which maintains entries for magazines, books and journals. For books titles, subject area ,author names ,publisher name, edition and year are to be stored. For magazines, name ,volume number and date etc are to be stored for journals subject name, subject area, list of articles ,editiors…etc is to be stored. Further for each article the author name, title,and some identification for the journal in which it appeared must be stored.

a) Give the DTD for the XML schema for the described system.

b) Write the following queries in XQuery

i) Display books, Magazine and journals sorted by year.

ii) Find all authors who have written a book and also a journal article in the same year.

1 Answer
0
54views
<! DOCTYPE LibDB [
<!ELEMENT LibDB (magazine*,book*,journal*)>
<!ELEMENT book(title,subject_area,author+,publisher,edition,year)>
<!ELEMENT magazine(name,volume_no,date)>
<!ELEMENT journal(subject_area,subject_name,article+,editor)>
<!ELEMENT article(author,title,journalid,year)>
<!ELEMENT author(last_name,first_name)>
<!ELEMENT title(#PCDATA)>
<!ELEMENT subject_area(#PCDATA)>
<!ELEMENT publisher(#PCDATA)>
<!ELEMENT edition(#PCDATA)>
<!ELEMENTS year(#PCDATA)>
<!ELEMENTS name(#PCDATA)>
<!ELEMENTS volume_no(#PCDATA)>
<!ELEMENTS date(#PCDATA)>
<!ELEMENTS subject_name(#PCDATA)>
<!ELEMENTS title(#PCDATA)>
<!ELEMENTS editor(#PCDATA)>
<!ELEMENTS journalid(#PCDATA)>
<!ELEMENTS first_name(#PCDATA)>
<!ELEMENTS last_name(#PCDATA)>
]>

b) 1.

for $x in(/LibDB/book)|
    	     (/LibDB/magazine)|
    	     (LibDB/journal)|
         Return $x sort by (year)
    1. For $a in distinct(/LibDB/book/author), $y in /LibDB/book[author=$a]/year, $art in /LibDB/journal/article[ author=$a and year= $y] Return $art
Please log in to add an answer.