Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Preparation: At the bottom of this assignment there is a sample XML document, and that you should cut and paste into a file bib.xml. A
Preparation: At the bottom of this assignment there is a sample XML document, and that you should cut and paste into a file bib.xml. A variant of the same information also appears in JSON format at the end of this document. You should also cut and paste it into a file bib.json, so you can see it more cleanly. Finally, an (imperfect) DTD for the XML document is given. (It really should have (author* | editor*) instead of author*,editor*.) Your first task is to write XPath and JSON queries. (1). Write Xpath queries for the following. Shorter queries receive higher credit. You MUST test your queries by going to https://www.freeformatter.com/xpath-tester.html cuting and pasting the contents of bib.xml into the top window, then trying each Xpath query, and pasting the query and result into your answer. a) Find the titles of all journals. (The answers should be elements) b) Find the text _strings_ of the tiles of all publications (books or journals) c) List the first names of all authors of some book. d) List the titles of books published after 1995 and costing less than 100. e) Find titles of publications without authors. (2) Write mongoDB queries/reads for the following. You MUST test your queries by going to https://docs.mongodb.com/manual/tutorial/query-documents/ cutting and pasting the db.bib.insertMany(...) command at the bottom of this document into the web shell, and afterwards running each of your queries in the form db.bib.___(___).pretty() . Your answer should contain the query and the answer returned. a) Find all titles of periodicals (show title:value pairs, no other information) b) Find all titles of journals c) List the titles of books published after 1995 and costing less than 100. d) List all books whose authors include someone with first name "W." e*) *List the first names of all authors of some book. (3)** If you go to https://www.freeformatter.com/xml-to-json-converter.html#ad-output convert bib.xml to JSON, you will see that the result is not the same as the bib.json I included below - it uses arrays. [In fact if you translate it back to XML the document is different!! Not a good feature!] For a more challenging homework try to write the queries in (2) using this translation (it will involve learning the mongDB (nested) array operators). (4) Derive a relational schema for storing documents that are valid according to the DTD at the bottom, following the procedure described in lecture * draw the graph * specify the relational schema (table & column names; underline keys; indicate with arrows foreign key references) [Please be sure the pictures are readable after you have uploaded them] =============================== Example XML document====================== Command to create example collection of publication documents: db.bib.insertMany( [ {type : "book", "@year": "1994", "title": "TCP/IP Illustrated", "author": { "last": "Stevens", "first": "W." }, "publisher": "Addison-Wesley", "price": "65" }, {type : "book", "@year": "1992", "title": "Unix Programming", "author": { "last": "Stevens", "first": "W." }, "publisher": "Addison-Wesley", "price": "65" }, {type : "book", "@year": "2000", "title": "Data on the Web", "author": [ { "last": "Abiteboul", "first": "Serge" }, { "last": "Buneman", "first": "Peter" }, { "last": "Suciu", "first": "Dan" } ], "publisher": "Morgan Kaufmann", "price": "39" }, {type : "book", "@year": "1999", "title": "Digital TV", "editor": { "last": "Gerbarg", "first": "Darcy", "affiliation": "CITI" }, "publisher": "Kluwer", "price": "130" } , {type : "journal", "title": "Irreproducible results", "editor": { "last": "Self", "first": "W." }, "publisher": "SV" } ]) ###################### Possible DTD for bib.xml above everything else is #PCDATA TCP/IP Illustrated Stevens W. Addison-Wesley 65 Unix Programming Stevens W. Addison-Wesley 65 Data on the Web Abiteboul Serge Buneman Peter Suciu Dan Morgan Kaufmann 39 Digital TV Gerbarg Darcy CITI Kluwer 130 Irreproducible results Self W. SV
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started