Wilde
Project Information
- Project Name: 'Product X'
- Location: 'Bellaire'
- Company: Company projects
- Worker Names: 'Smith', 'Joyce'
- Worker Numbers: '123456789', '435435435'
- Last Hours: 20.0
- San First Hours: CZ2007
Introduction to Databases: Semi-Structured Data
- Professor: Cong Gao
- School: School of Computer Science and Engineering
- University: Nanyang Technological University, Singapore
Roadmap: Semi-Structured Data
- Topics:
- Semi-structured Data
- XML
- XML DTD
- JSON
The Value of Data
- The More Data, The Merrier:
- Volume: GB -> TB -> PB
- Variety: Data comes from everywhere in all shapes
- Value: Often discovered later
- Power of Data:
- The more services the merrier (10 -> 1000 -> 1M -> 1B)
- Goal: Platforms for data and services
- Services turn data into $$$
- Accessibility: Any data, any service, anywhere, and anytime
Data Sources and Types
- Data Sources:
- Client Machines (Browser, Adobe Air, Adobe Flex, Mobile Games)
- Servers of utility provider
- Communication: REST (http)
- Data Storage: DB
- Data Variety: Doc, Internal & External Data
- Network: Internet
Structured vs. Unstructured Data
- Relational Databases (Structured):
- Data resides in tables.
- Schema must be defined before data entry.
- Every row conforms to the table schema.
- Changing the schema is difficult and can break many things.
- Texts (Unstructured):
- Data is free-form.
- No schema, and it’s hard to define one.
- Readers need to infer structures & meanings.
- Question: What’s in between these two extremes?
Semi-Structured Data
- Observation: Most data have "some" structure.
- Examples:
- Book: chapters, sections, titles, paragraphs, references, index.
- Item for sale: name, picture, price, ratings, promotion.
- Web page: HTML.
- Examples:
- Ideas:
- Ensure data is "well-formatted."
- If needed, ensure data is also "well-structured."
- But make it easy to define and extend this structure.
- Make data "self-describing."
A Brief History
- Database World:
- 1970: Relational databases
- 1990: Nested relational model and object-oriented databases
- 1995: Semi-structured databases
- Documents World:
- 1974: SGML (Structured Generalized Markup Language)
- 1990: HTML (Hypertext Markup Language)
- 1992: URL (Universal Resource Locator)
- Data + Documents = Information
- 1996: XML (Extensible Markup Language)
- URI (Universal Resource Identifier)
XML as Semi-Structured Data
- XML Definition: The EXtensible Markup Language
- Purpose: A flexible syntax for data: semi-structured data
- Use Cases:
- Configuration files (e.g., Web.Config)
- Replacement for binary formats (MS Word)
- Document markup (e.g., XHTML)
- Data exchange, semistructured data (sensor data, logs, blogs)
- Warning: Not normal form! Not even 1NF
- Popularity: XML is about half as popular as SQL
From HTML to XML
- HTML Example:
- Displays a bibliography with two entries, including the titles, authors, and publication information.
- HTML - The HyperText Markup Language
- HTML describes the presentation
HTML Characteristics
- It’s mostly a “formatting” language
- It mixes presentation and content
- HTML - The HyperText Markup Language
XML Example
- XML Example:
- Presents the same bibliographic information as the HTML example but focuses on the data content and structure, using tags to define elements like
<title>,<author>,<publisher>, and<year>. This structure makes it easier to process and extract data.
- Presents the same bibliographic information as the HTML example but focuses on the data content and structure, using tags to define elements like
- XML - The EXtensible Markup Language
- XML describes the content
XML Characteristics
- Text-based
- Capture data (content), not presentation
- Data self-describes its structure
- Names and nesting of tags have meanings!
- XML - The EXtensible Markup Language
HTML vs. XML
- Difficulties with HTML:
- Fixed set of tags
- Elements have document structuring semantics
- For presentation to human readers
- Applications cannot consume and process HTML easily
- These difficulties are not in XML
XML Terminology
Given the XML:
<bibliography> <book ISBN="ISBN-10" price="80.00"> <title>Foundations of Databases</title> <author>Abiteboul</author> <author>Hull</author> <author>Vianu</author> <publisher>Addison Wesley</publisher> <year>1995</year> </book> </bibliography>Terminology:
- Tag names: book, title, …
- Start tags:
, - End tags: , , …
- An element is enclosed by a pair of start and end tags:
… - Elements can be nested:
…… - Empty elements:
Can be abbreviated: - Elements can also have attributes:
- Element Ordering generally matters, but not for attributes
Well-formed XML Documents
- A well-formed XML document:
- Follows XML lexical conventions
- Wrong:
<section>We show that x < 0…</section> - Right:
<section>We show that x < 0…</section> - Other special entities: > becomes
>and & becomes&
- Wrong:
- Contains a single root element
- Has properly matched tags and properly nested elements
- Right:
<section>…<subsection>…</subsection>…</section> - Wrong:
<section>…<subsection>…</section>…</subsection>
- Right:
- Follows XML lexical conventions
Tree Representation of XML Documents
- XML documents can be represented as trees, where elements are nodes, and nesting is represented through parent-child relationships.
XML Attributes Example
Example:
<book price = "55" currency = "USD"> <title> Foundations of Databases </title> <author> Abiteboul </author> <year> 1995 </year> </book>
Attributes vs. Elements
Using attributes and elements to represent data
<book price = "55" currency = "USD"> <title> Foundations of DBs </title> <author> Abiteboul </author> <year> 1995 </year> </book> <book> <title> Foundations of DBs </title> <author> Abiteboul </author> <year> 1995 </year> <price> 55 </price> <currency> USD </currency> </book>Attributes are alternative ways to represent data
Attribute Uniqueness
- Attribute names must be unique! (No Multisets)
- `<person name =