) - version 2svoboda/courses/192-mdk/...exercise2 extendthepreviousxmldocument •...
TRANSCRIPT
![Page 1: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/1.jpg)
MDK:Modern Database Conceptsh p://www.ksi.mff.cuni.cz/~svoboda/courses/192-MDK/
Prac cal Class 1
FormatsMar n [email protected]
3. 4. 2020
Charles University, Faculty of Mathema cs and PhysicsOTH Regensburg, Faculty of Computer Science and Mathema cs
![Page 2: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/2.jpg)
XML
![Page 3: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/3.jpg)
Sample XML Document
<?xml version="1.1" encoding="UTF-8"?><movie year="2007">
<title>Medvídek</title><actors>
<actor><firstname>Jiří</firstname><lastname>Macháček</lastname>
</actor><actor>
<firstname>Ivan</firstname><lastname>Trojan</lastname>
</actor></actors><director>
<firstname>Jan</firstname><lastname>Hřebejk</lastname>
</director></movie>
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 3
![Page 4: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/4.jpg)
Exercise 1Create a new XML document for data of a simple social network
• Use, e.g., the following editor and validatorh ps://codebeau fy.org/xmlvalidator
• Add the following basic constructsXML prologueRoot element friendsIts only empty element users
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 4
![Page 5: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/5.jpg)
Exercise 2Extend the previous XML document
• Add data about one par cular userId: u121Name: PeterAge: 35Email: [email protected]
• Use a ributes for id and age, use elements otherwise
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 5
![Page 6: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/6.jpg)
Exercise 3Extend the previous XML document
• Add data about two addi onal usersId u654, name Rachel, 25 yearsId u357, name John, 30 years,email addresses [email protected] [email protected],phone number +420 777 555 111
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 6
![Page 7: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/7.jpg)
Exercise 4Extend the previous XML document
• Create groups element a er the exis ng users element• Add data about the following two groups
Id g11, name PhotographersId g24, name Librarians
• Note that groups can be recursively nested into each other• Add the following group as a sub-group of group g11
Id g15, name Landscape Photographers
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 7
![Page 8: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/8.jpg)
Exercise 5Extend the previous XML document
• Add friend rela onships between individual usersUser u654 knows users u121 and u357User u357 knows user u987
• Addmember rela onships between groups and usersGroup g15 contains users u121 and u357Group g24 contains user u121
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 8
![Page 9: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/9.jpg)
Exercise 6Extend the previous XML document
• Create posts element a er the exis ng groups element• Add the following posts published by user u121
Id p530035, date me 2018-10-08 09:30:00,tle New trends in libraries
Id p530045, date me 2018-10-08 09:45:00,tle Great photos of my family
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 9
![Page 10: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/10.jpg)
JSON
![Page 11: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/11.jpg)
Sample JSON Document
{"title" : "Medvídek","year" : 2007,"actors" : [
{"firstname" : "Jiří","lastname" : "Macháček"
},{
"firstname" : "Ivan","lastname" : "Trojan"
}],"director" : {
"firstname" : "Jan","lastname" : "Hřebejk"
}}
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 11
![Page 12: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/12.jpg)
Exercise 7Create a new JSON document for data of our social network
• Use, e.g., the following editor and validatorh ps://codebeau fy.org/jsonvalidator
• Add the following proper es of the main objectusers, groups, and postsAssociate all of them with empty values (null)
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 12
![Page 13: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/13.jpg)
Exercise 8Extend the previous JSON document
• Add data about our three usersId: u121, name Peter, age 35,email address [email protected] u654, name Rachel, 25 yearsId u357, name John, 30 years,email addresses [email protected] [email protected],phone number +420 777 555 111
• Also add all friendshipsUser u654 knows users u121 and u357User u357 knows user u987
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 13
![Page 14: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/14.jpg)
Exercise 9Extend the previous JSON document
• Add data about the following groupsId g11, name PhotographersId g15, sub-group of g11, name Landscape PhotographersId g24, name Librarians
• Also add all membershipsGroup g15 contains users u121 and u357Group g24 contains user u121
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 14
![Page 15: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/15.jpg)
Exercise 10Extend the previous JSON document
• Add the following posts published by user u121Id p530035, date me 2018-10-08 09:30:00,tle New trends in libraries
Id p530045, date me 2018-10-08 09:45:00,tle Great photos of my family
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 15
![Page 16: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/16.jpg)
RDF
![Page 17: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/17.jpg)
Sample RDF Document
<http://db.cz/movies/medvidek><http://db.cz/terms#actor> <http://db.cz/actors/machacek> .
<http://db.cz/movies/medvidek><http://db.cz/terms#actor> <http://db.cz/actors/trojan> .
<http://db.cz/movies/medvidek><http://db.cz/terms#year> "2007" .
<http://db.cz/movies/medvidek><http://db.cz/terms#director> _:n18 .
_:n18<http://db.cz/terms#firstname> "Jan" .
_:n18<http://db.cz/terms#lastname> "Hřebejk" .
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 17
![Page 18: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/18.jpg)
Exercise 11Create a new RDF document for our data
• Use, e.g., the following editor and validatorh p:// l.summerofcode.be/
• Add statements about the following userName Peter, age 35, email [email protected] http://www.friends.cz/users/u121as an IRI iden fier for this userAssume all proper es (e.g. name, …) belong to a prefixhttp://www.friends.cz/schema#Also add an RDF type descrip on, i.e. associate our user withhttp://www.friends.cz/schema#User using propertyhttp://www.w3.org/1999/02/22-rdf-syntax-ns#type
• Only use full triples and IRI iden fiers
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 18
![Page 19: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/19.jpg)
Exercise 12Modify the previous RDF document
• Define and use prefix declara ons provided by Turtlerdf forhttp://www.w3.org/1999/02/22-rdf-syntax-ns#schema for http://www.friends.cz/schema#user for http://www.friends.cz/users/
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 19
![Page 20: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/20.jpg)
Exercise 13Extend the previous RDF document
• Add data about the following usersId u654, name Rachel, 25 yearsId u357, name John, 30 years,email addresses [email protected] [email protected],phone number +420 777 555 111
• Include rdf:type statements as well
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 20
![Page 21: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/21.jpg)
Exercise 14Modify the previous RDF document
• Compact all your statements using object andpredicate-object lists
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 21
![Page 22: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/22.jpg)
Exercise 15Extend the previous RDF document
• Add data about the following groupsId g11, name PhotographersId g15, sub-group of g11, name Landscape PhotographersId g24, name Librarians
• Use the following prefix for groupshttp://www.friends.cz/groups/
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 22
![Page 23: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/23.jpg)
Exercise 16Extend the previous RDF document
• Add the following friendshipsUser u654 knows users u121 and u357User u357 knows user u987
• Also add the following membershipsGroup g15 contains users u121 and u357Group g24 contains user u121
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 23
![Page 24: ) - Version 2svoboda/courses/192-MDK/...Exercise2 ExtendthepreviousXMLdocument • Adddataaboutoneparcular user Id:u121 Name:Peter Age:35 Email:peter@friends.cz • Useaributesforidandage,useelementsotherwise](https://reader035.vdocuments.mx/reader035/viewer/2022070112/60563b7f9df0233d6a1203ba/html5/thumbnails/24.jpg)
Exercise 17Extend the previous RDF document
• Add the following posts published by user u121Id p530035, date me 2018-10-08 09:30:00,tle New trends in libraries
Id p530045, date me 2018-10-08 09:45:00,tle Great photos of my family
• Represent both the post as blank nodesUse _:… approach for the first oneUse [ … ] Turtle shortcut for the second one
MDK: Modern Database Concepts | Prac cal Class 1: Formats | 3. 4. 2020 24