1
Designing Semistructured Databases Using ORA-SS Data Model
ORA-SS: An Object-Relationship-Attribute Model for
Semistructured Data
2
Contents Part I. ORA-SS: An Object-Relationship-Attribute
Model for Semistructured Data – Object class – Relationship Type – Attribute – Semistructured data instance – Functional dependencies and other constraints – Inheritance hierarchy
Part II. Applications of ORA-SS Model – Normal form ORA-SS schema diagram – Storage schema for ORA-SS/XML databases – ORA-SS/XML views – Evaluating XML queries on ORA-SS databases – Translating relational schema into ORA-SS schema – Integration of XML documents
3
Motivation – An XML Document <department number =“cs”> <name> computer science</name> <course number = “cs4221”> <name> Database </name> <student number = “1234” > <name> B.Y.Smith</name> <grade> 70</grade> </student> <student number=“1235”> <name> C.U.Brown </name> <grade> 60 </grade> </student> … </course> … </department>
<! ELEMENT department (name,course+)> <! ATTLIST department number ID #REQUIRED> <! ELEMENT course (name, student*)> <! ATTLIST course number ID #REQUIRED> <! ELEMENT student (name, grade?)> <! ATTLIST student number CDATA #REQUIRED> <! ELEMENT name (#PCDATA)> <! ELEMENT grade (#PCDATA)>
(a) XML document
(b) An XML DTD for (a)
Notes: (1) Student’s number cannot be declared as ID. (2) The subelements name and grade are defined in the
same way. However, name is a property of student but grade is a relationship attribute.
4
Motivation (cont.)
(a) OEM Diagram Figure 1: Sample instance demonstrating OEM and Dataguide
♦ number
(b) Dataguide
▼♦ department
▼♦ student
▼ ♦ course ♦ name ♦ number
♦ name ♦ grade
♦ number ♦ name
department
cs
student
number name
computer science
&3
&1
course course
number
&20
name
&21 &22
number
grade
1234 B.Y.Smith 70 1235 C.U. Brown 60
cs4221 Database
&26
&7
student
&4
&2
name
&5
student
&6
number
&23
name
&24
grade
&25
number name
&27 &28
name of student and grade are defined in the same way. Bad!
5
Motivation (cont.)
Figure 3: ORA-SS schema diagram
number: CS4221
Student
Figure 2: ORA-SS instance diagram
name: Computer
Science course course
number: CS
department
name: Database
student
number: 1234
name: B.Y. Smith
grade: 70
student
number: 1235
name: C.U. Brown
grade: 60
number name
number
department
course 2, 1:n, 1:1
student number name
name grade
cs
number name CS, 2, *, +
Note: grade is declared as an attribute of the binary relationship type cs.
6
ORA-SS - The Data Model Object class
– attributes of object class – ordering on object class – weak object class
Relationship Type – attributes of relationship type – degree of n-ary relationship type – participation of objects in relationship type – disjunctive relationship type – recursive relationship type – IDD (identifier dependency) relationship type
Note that DTD and XML Schema have no concept of relationship type, they only describe the hierarchical structure of the xml documents.
Reference
7
ORA-SS
The Data Model (cont.)
Attribute – Attribute of object class or relationship type – key attribute (identifier) – composite attribute – disjunctive attribute – attributes with unknown structure – ordering on attribute – fixed and default values of attribute – derived attribute
Semistructured data instance
Functional dependencies and other constraints
Inheritance hierarchy
8
The data model of ORA-SS
Object Class
student
number first name last name
Figure 4: Object class student with attributes in an ORA-SS schema diagram
– represented by a rectangle
– attributes of object class by a circle
– identifier of object class by a filled circle
– ordering on object class by a symbol <
identifier Single valued
attribute
Object class
9
The data model of ORA-SS Relationship Type
– attributes of relationship type – degree of n-ary relationship type – participation of objects in relationship type – disjunctive relationship type – recursive relationship type
project
id name member
name job title publication
number title
2, +, +
2, *, +
(a) ORA-SS Schema Diagram
(b) Relationship instance
♦ number ▼♦ publication
▼♦ project
▼♦ member ♦ name
♦ title
♦ job title
♦ name ♦ id
(c) Dataguide
Figure 5: Representing binary relationship type
p1
p2
p3
m1
m2
pub1 pub2
pub3
project member publication
10
The data model of ORA-SS
Relationship Type (cont.)
project
id name member
name job title publication
number title
2, +, +
3, *, +
(a) ORA-SS Schema Diagram
Figure 6: Representing ternary relationship type
(b) Relationship instance
p1
p2
p3
m1
m2
pub1 pub2
pub3
project member publication
(c) Dataguide
♦ number ▼♦ publication
▼♦ project
▼♦ member ♦ name
♦ title
♦ job title
♦ name ♦ id
11
The data model of ORA-SS
IDD Relationship Type Some object classes may not have identifier. E.g. chapters of a book do not have a unique
identifier.
However, a chapter of a book can be identify by the identifier of the book (i.e. ISBN) and the chapter number of the chapter.
We call the object class chapter a weak object class with a weak identifier chapter_no.
The relationship type between book and chapter is called an identifier dependency (IDD) relationship type. Chapter is a dependent object class of the book object class.
It is similar to weak entity type and ID relationship type in ER approach.
IDD
book
chapter
section
ISBN title author
+
IDD
chapter_no
section_no
Figure: IDD relationship types
12
The data model of ORA-SS Attribute
– key attribute or Object Identifier (OID) – Attribute of object class and relationship type – composite attribute – disjunctive attribute (denoted by | ) – attribute with unknown structure (denoted by ANY)
– ordering on attribute (denoted by < )
– fixed and default values of attribute (denoted by F and D)
– derived attribute (denoted by dotted circle)
hobby
course
student * cno title ANY
dept prefix D: comp
number * sno first
name last name
mark grade
cs cs
cs, 2, 4:n, 3:8
Figure 7: Object classes with relationship type and attributes in an ORA-SS schema diagram
composite attribute
CS is a binary relationship type
Each course has min 4 students and no max.
mark is a CS relationship
attribute
Frist_name and last_name form a composite key
Each student min takes 3 courses and max 8.
13
The data model of ORA-SS Ordering
– the instances of an object class can be ordered, – the values of an attribute can be ordered, and – the set of attributes of an object class can be ordered
Figure 8: Ordered object classes and attributes in an ORA-SS schema diagram
book
isbn
chapter
number
IDD title
section
number
2,1:n, 1:1, <
3,1:n, 1:1, < IDD
author +
<
14
The data model of ORA-SS Disjunction
– disjunctive object class, and – disjunctive attribute.
Figure 9: Disjunctive attribute and relationship type in an ORA-SS schema diagram
cno
number street
course
title Exam_venue
lecture theatre laboratory student
sno name grade
hostel
cs, 2, 4:n, 3:8
address cs
house
15
The data model of ORA-SS References
Figure 10: Referencing an object class in an ORA-SS Schema Diagram
Student’
grade
cs, 2, 1:n, 1:m
cs
course
title cno
lecture theatre
laboratory
* text
book
student
sno address
first name
last name
name exam venue
sno
- Similar to IDREF in DTD
Note: name is a composite attribute
16
The data model of ORA-SS References (cont.)
Figure 11: Example of a recursive relationship type in an ORA-SS Schema Diagram
course
cno title prereq
2, 0:5, 1:n
prereq-cno
17
The data model of ORA-SS References (cont.)
Figure 12: Representing a binary relationship type as 2 symmetric relationship types to facilitate symmetric queries. Redundancy occurs.
cs
course
Student’
cno number of students
cs, 2, +, +
student
Course’
sno name
sc, 2, +, +
grade sno cno
sc
grade
18
The data model of ORA-SS Functional Dependencies
student, course → tutor tutor → course
1/n
n/1 n/- student course
tutor
sct
Figure 15: Functional dependencies diagram
19
The data model of ORA-SS Inheritance Hierarchy
(a) ORA-SS Schema Diagram
staff number
person
payrate degree
student
tutor
ssn
sno
faculty
(b) Inheritance Diagram
Figure 16: ORA-SS schema diagram and inheritance diagram
staff number sno
3,+,+ 3,+,+ grade title
sc, 2,+,+ sno
course
student
faculty tutor
ssn ssn payrate degree
ssn
cno sc
sno is another key
20
The data model of ORA-SS Constraints Inclusion dependency Semantic dependencies
(a) jdate of employee joined company, i.e. jdate is semantically determined by employee only.
(b) jdate of employee joined department, i.e. jdata is semantically determined by employee and department.
Figure 17: Modeling join date (jdate) ORA-SS schema diagram
ed, 2, 1:n, 1:1
jdate name ssn
department
employee
?
dno
ed
name 2,1:n,1:1
jdate name ssn
department
employee
?
dno name