1 / 42

OODB and XML

OODB and XML. Database Management Systems – Fall 2012. Matthew Moccaro. Outline. 1. OODB. 2. OODB AND SQL. 3. XML. 4. XML Queries. Object Databases. Object Databases. Object Databases. A History. First arrived in the 1980s and 1990s Use objects to represent data with a set of

tanith
Download Presentation

OODB and XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OODB and XML Database Management Systems – Fall 2012 Matthew Moccaro

  2. Outline 1. OODB 2. OODB AND SQL 3. XML 4. XML Queries

  3. Object Databases Object Databases

  4. Object Databases A History • First arrived in the 1980s and 1990s • Use objects to represent data with a set of • attributes. • Developed due to certain limitations of the • very popular relational model. • Let’s take a look at an example of oneof • these limitations.

  5. Limitations Example: Part 1

  6. Limitations Example: Part 2

  7. Limitations Example: Part 3 Explanation • There are several ways around this problem, • however, they normally lead to more difficulties. • More tables, more complex queries. • Our solution can be an OODB. To help explain • an object database, let’s compare it to something • we are familiar with, the relational model.

  8. Object Vs. Relational: Part 1 Object Database Relational Database Contains Classes which are: Sets of Objects Contains Relations which are: Sets of Tuples

  9. Object Vs. Relational: Part 2 Object Database Relational Database Components of an object can be complex types. Sets, Tuples, Objects….. Components of a tuple must be primitive types. Strings, Integers…

  10. Object Vs. Relational: Part 3 Object Database Relational Database • Objects can have inheritance. • Objects can have methods. • Can be all in the same language. N/A

  11. OODB The Conceptual Object Data Model TEXT TEXT • Helps us to understand OODB. • Let’s take a better look at: • Objects • Classes • Types

  12. The Conceptual Object Data Model Objects TEXT TEXT • In this model, each object has an individual ID. • Called an “oid” • Different from a Primary Key • Cannot change for an object • Values • Can Change • Can be complex

  13. The Conceptual Object Data Model Classes TEXT TEXT • Organizes similar objects • Class called Person contains objects with • information regarding each person. • Classes Have: • Type • Method Signatures • Extent

  14. The Conceptual Object Data Model Types TEXT TEXT • Types could be: • Basic • Reference • Tuple • Set • Subtype and Supertype

  15. Object-Relational Database Object Relational Database • Combination of Object and Relational Databases • Top Level Classes which contain tuples. • These classes are called “relations.” • Tuples are “tuple objects.” • Top level structure is always a tuple. • Can have complex values.

  16. Object Databases Object Databases and SQL

  17. Object Databases A History • First added to SQL in SQL:1999 • Created with backwards compatibility in mind. • SQL-92 • Remained in SQL:2003, SQL:2008, • and SQL:2011.

  18. Row Type A New Type • To create a tuple type in SQL, we can now use the row keyword: • CREATE TABLE Person( • Name CHAR(20), • Address ROW(Number INTEGER, STREET CHAR(20), ZIP CHAR(5))) • To insert new values: • INSERT INTO Person(Name, Address) • VALUES (‘John Doe’, ROW(666, ‘Hollow Rd.’, ‘66666’))

  19. Creating Objects Creating A Type • To create an object in SQL, we need to go through a few steps. • First we can define a type. • CREATE TYPEStudentTypeAS( • Address ROW(Number INTEGER, STREET CHAR(20), ZIP CHAR(5))) • Id INTEGER, • Status CHAR(2));

  20. Creating Objects Creating A Table • Next, we can create a new table from our type. • CREATE TABLE Student OFStudentType; • SQL regards the rows of a table declared in this way as objects. • The book introduces many other new concepts in this area.

  21. XML XML

  22. XML A History • XML was first developed in the late 1990s and • came into popularity soon after. • EXtensibleMarkup Language • HTML displays data, XML carries data • File Extension is .xml • Let’s create a file….

  23. XML Example File First, we can start by making an XML declaration….. <?xml version=“1.0” encoding=“UTF-8” ?>

  24. XML Example File Comments are done as <!-- Comment --> <?xml version=“1.0” encoding=“UTF-8” ?> <!- - Written By: Matt - - >

  25. XML Example File Let’s make a menu. So we’ll declare some menu tags. This is called the root element. <?xml version=“1.0” encoding=“UTF-8” ?> <!- - Written By: Matt - - > <menu> All elements must have an open </menu> andclose tag. Close tags have a “/”

  26. XML Example File Now let’s put an entrée section. <?xml version=“1.0” encoding=“UTF-8” ?> <!- - Written By: Matt - - > <menu> <entree> </entree> </menu>

  27. XML Example File Let’s add some details. How about a name? <?xml version=“1.0” encoding=“UTF-8” ?> <!- - Written By: Matt - - > <menu> <entree> <name>Sunburnt Chicken</name> </entree> </menu>

  28. XML Example File And a detail about this entrée. <?xml version=“1.0” encoding=“UTF-8” ?> <!- - Written By: Matt - - > <menu> <entree> <name>Sunburnt Chicken</name> <fatgrams>23</fatgrams> </entree> </menu>

  29. XML Example File Let’s add an entirely new entrée. <?xml version=“1.0” encoding=“UTF-8” ?> <!- - Written By: Matt - - > <menu> <entree> <name>Sunburnt Chicken</name> <fatgrams>23</fatgrams> </entree> <entree> <name>Gusto Spaghetti</name> <fatgrams>55</fatgrams> </entree> </menu>

  30. XML Example File Attributes can help make things more clear. We could do this…. <?xml version=“1.0” encoding=“UTF-8” ?> <!- - Written By: Matt - - > <menu> <entrée1> <name>Sunburnt Chicken</name> <fatgrams>23</fatgrams> </entrée1> <entrée2> <name>Gusto Spaghetti</name> <fatgrams>55</fatgrams> </entrée2> </menu>

  31. XML Example File But you can also add attributes within a tag. <tagname something = “value” > <?xml version=“1.0” encoding=“UTF-8” ?> <!- - Written By: Matt - - > <menu> <entrée id = “1”> <name>Sunburnt Chicken</name> <fatgrams>23</fatgrams> </entrée> <entrée id = “2”> <name>Gusto Spaghetti</name> <fatgrams>55</fatgrams> </entrée> </menu>

  32. XML XML • Can be formatted in several ways. • CSS • XSLT • Documents can be validated by: • XML Schemas • DTDs • Let’s take a look at some XML queries….

  33. XML Queries XML Queries

  34. XML Queries DTD XSLT XML Schema XML XQuery XPath

  35. XML Query Languages XQuery XPath XSLT Solutions for XML Queries

  36. XPath XPath • XML Query Language which views XML documents as trees. • Things such as comments and elements • are nodes of these trees. • Allows us to traverse the tree and find a • “path” to what we need. • Gives us an easy to understand language for • querying XML Documents.

  37. XSLT XSLT • XSLTransformation • Files usually called stylesheets. • Can be used to query and to format XML • Includes conditional instructions…. • More powerful query language which can • utilize parts of XPath. • Certain queries such as joins can still be • difficult in XSLT.

  38. XQuery XQuery • Built by taking the best parts of two other query languages, XQL and XML-QL. • Still uses XPath as a syntax for its expressions. • More similar to SQL: • FOR (variable declarations) • WHERE (condition) • RETURN (result)

  39. SQL/XML SQL/XML • Slowly becoming part of the SQL standard. • Allows us to work directly with XML documents from SQL. • Many vendors such as Oracle, MS SQL Server, MySQL, and PostgreSQL already have much functionality built-in.

  40. Summary 1. OODB Object Databases help us to excel where the relational model may be cumbersome. 2. OODB AND SQL Allow us to integrate objects into our databases while still utilizing SQL. 3. XML A highly customizable language which helps us to represent data almost universally. 4. XML Queries Gives us many different languages to use XML to its full potential.

  41. The End Thank You!

  42. References: References: Wagner, Richard and Richard Mansfield. XML for Dummies For Dummies. 2003. Kifer, Michael and Arthur Bernstein, and Philip M. Lewis Database Systems Boston: Pearson Education, 2006 XML Tutorial. W3 Schools. 2012 Web. Nov. 2012 http://www.w3schools.com/xml/ SQL/XML. Wikipedia. 2012 Web. Nov. 2012 http://en.wikipedia.org/wiki/SQL/XML

More Related