SIM Example: Organization Schema Unisys Person

advertisement
Enterprise
Server
Division
Unisys
SIM Example:
Organization Schema
Person
Name (First-Name, Mid-Initial, Last-Name)
Current-Residence (Street, City, State, ZipCode)
Education (Degree-Obtained, Year-Obtained, GPA) MV
Next-of-Kin (Relationship, Phone, Name-Of-Kin (First-Name, Mid_Initial, Last-Name))
Marital-Status
US-Citizen
Soc-Sec-No
Birth-Date
Gender
Age
Child
Parent
Previous-Employee
Termination-Reason
Leave-Status
Last-Work-Date Hire-Date
Project-Employee
Title
Overall-Rating
Dept-In
Employee
Employee-ID
Employee-Hire-Date
Employee-Salary
Employee-Status
Spouse
Employee-Manager
Employees-Managed
Manager
Interim-Manager
Interim-History
(Start-Date,
End-Date) MV
Manager-Title
Bonus
Dept-Staff
Project-Manager
Department
Staff-Assigned
Assignment
Start-Date AssignmentNo
End-Date Rating
Est-Person-Hours
(Next-Project-No)
Project-No
Project-Title
Project-Of
Assignment-History
Sub-Projects
Assignment-Record
Project
Dept-Assigned
Sub-Project-Of
Dept-No
Dept-Title
Dept-Location
Projects-Managing
Enterprise
Server
Division
Unisys
SIM
Origins and Evolution
Doug Tolbert
Unisys Corporation
Mission Viejo, CA
Unisys
SIM Motivations: Objectives (1983)
Ease of Use
•
•
•
Integrated, high level interface
Query & schema flexibility
Data Independence
Productivity
•
•
Set-oriented, non-procedural
interface
Naturally handle complexity
Data Integrity
•
•
•
System enforced integrity
Shared data definitions
Referential integrity
Coexistence
•
No impact on DMS II customer
base
New capabilities for existing data
•
Performance
•
Must support production level
transaction processing systems
•
•
•
Easy to learn
Minimal programming effort
Retrieval without programming
•
•
•
Fast
Fast
Fast
Enterprise
Server
Division
Unisys
Enterprise
Server
Division
SIM Motivations: Options (1983)
Enhance DMS II
•
Improve ease of use
•
Gain productivity &
data integrity without
sacrificing installed
base
•
•
Relational System
•
Ease of use would
improve
•
Productivity gains
marginal
•
Performance thought
to be near architectural
limits (but wasn’t true!)
Data integrity very
limited
•
Extensive data engine
rework
Not likely to expand
customer base
•
No migration path for
customer base
•
Performance?
•
Late to market
Something New
•
Designed to meet
Ease of use,
productivity, and data
integrity goals
•
New features for
existing databases
without migration
•
Performance based on
proven DMS II
algorithms
•
Semantic Data Model
provided best
framework
Unisys
Enterprise
Server
Division
SIM: Something New!
Artificial Intelligence
Semantic Models
Semantic Networks
SDM
Quillian, Brachman
Hammer & McLeod
Graphical Data Models
Entity Relationship
Chen
SIM
Programmatic Model
DAPLEX
Shipman
Set Data Models
RM/T
Codd
Query Languages
GORDAS
El-Masri
Unisys
Enterprise
Server
Division
SIM: A Semantic Data Model
What makes a data model
“semantic”?
How does a semantic data model
capture meaning?
“During the last few years numerous
investigations have been aimed at capturing
(in a reasonably formal way) more of the
meaning of the data, while preserving
independence of implementation. This
activity is sometimes called semantic data
modelling. Actually, the task of capturing the
meaning of data is a never-ending one. So
the label ‘semantic’ must not be interpreted in
a absolute way.”
-- E. F. Codd, 1979
“... it is appropriate that the structure of a
database mirror the structure of the system
that it models. A database whose
organization is based on naturally occurring
structures will be easier for a database
designer to construct and modify than one
that forces him to translate the primitives of
his problem domain into artificial specification
construction.”
-- Hammer & McLeod, 1981
•
SDMs capture the meaning of data,
not just its physical representation
•
Schema objects should look like
corresponding real world objects
•
So, the more meaning a data model
captures, the more “semantic” it is
•
Meaning captured by object types,
relationships, attribute types,
cardinality constraints, active rules
Unisys
SIM Concepts:
Enterprise
Server
Division
Entities & Attributes
Entity
– An object or idea of interest in the application environment
– Does not imply a particular physical implementation
But functional analogs are records and tuples in other data models
– e.g., The employee named John Doe
The Accounting department
Attribute
– A characteristic of an entity
– John Doe has an address, an employee ID, a salary, ...
Unisys
SIM Concepts:
Enterprise
Server
Division
Classes & Subclasses
Class
– A collection of entities of the
same type
– Employee, the set of all
employees working for a
company
Employee
ISA
Subclass
– A subset of entities in a class
– Project-Employees are
employees that work on projects
Project-Employee
Unisys
SIM Concepts:
Enterprise
Server
Division
Attributes
Attribute Inheritance
– Subclasses inherit attributes from
all their superclasses
– Subclasses may declare
additional attributes
Employee
Name
EmployeeID
Attribute Types
– Data-Valued Attributes (DVA)
Have a printable value
– Entity-Valued Attributes (EVA)
Entities in another class
Model relationships
Project-Employee
Title
Department
Dept-In
Enterprise
Server
Division
Unisys
SIM Concepts:
Extended Attributes
Perspective Class
– A point of view class chosen
for a query
– Same data may have different
meanings from different
perspective classes
Employee
Name
EmployeeID
Extended Attributes
– Attributes of related entities
may be considered extended
attributes of the perspective
class
Project-Employee
Title
Department
Dept-In
Dept-No
Dept-No of Dept-In of Project-Employee = 123
Dept-No of Department = 123
Unisys
SIM Concepts:
Enterprise
Server
Division
Constraints & Relations
Attribute Constraints
–
–
–
–
–
Isomorphic for EVA/DVA
Single-Valued
Multi-Valued
Required
Unique
Relationships (EVAs)
– Always bi-directional
– Automatic referential integrity
– Transitive closure function
Employee
Name
EmployeeID
Dept-In
Project-Employee
Department
Title
Dept-No
Dept-Staff
Title of INVERSE(Dept-In) of Department
Title of Dept-Staff of Department
Unisys
SIM Concepts:
Enterprise
Server
Division
Data Types
Class Attributes
– One value per class, not associated with any entity, DVA only
Data Types
– Similar to Pascal, with relaxed string type checking
System Defined
•
•
•
•
•
•
Integer
Real
Boolean
Date
Time
Character
•
•
•
•
•
•
User Defined
Number
String (fixed)
String (variable)
Kanji
Symbolic
Ordered Symbolic
•
•
•
Based on system defined types
Set membership for strings
WeekDay : String(“Mon”, ..., “Fri”)
Enforced subrange
Employee-Age : Integer(18..70)
Unisys
SIM Concepts:
Verify
Verify
– General constraints not related to schema structure
– Full power of SIM expression syntax in WHERE clause
– For example
Spouses of employees hired after December 31, 1995, may not
work for the company
VERIFY
ASSERT
WHERE
ELSE
NoCouples ON Employee
Not (Spouse ISA Employee)
Employee-Hire-Date > 12/31/95
“Spouse may not work for company”
Enterprise
Server
Division
Unisys
SIM Concepts:
Enterprise
Server
Division
Security
Security
– Accesses limit visibility of and operations on attributes
– Permissions associate Accesses with users or programs
– For example
The Accounting Department may examine but not change the salary of
journeyman and higher employees
ACCESS
WHERE
LookButDontTouch ON Employee (Employee-Salary) RETRIEVE
Employee-Status >= Journeyman
PERMISSION USERCODE = Accounting, ACCESS = LookButDontTouch
Unisys
SIM Concepts:
Indexes
Indexes
– Multiple DVA keys, ascending or descending
– For performance improvement
– Visible to database administrators & query optimizer
– Not visible to programmers or query users
INDEX (Employee-ID) ON Employee ASCENDING
Enterprise
Server
Division
Unisys
SIM Concepts:
Enterprise
Server
Division
Expressions
Operators
Arithmetic
Boolean
Relational
String
Existence
+, -, *, /, DIV, MOD, **
NOT, AND, OR
<, >, =, <=, >=, <>
&, pattern matching
EXISTS
Functions
Arithmetic
String
Symbolic
Date
Time
Relationships
ABS, ROUND, TRUNC, SQRT
LENGTH, EXT, POS, RPT
PRED, SUCC
YEAR, MONTH, DAY, ELAPSED_DAYS, ADD_DAYS, DAY_OF_WEEK,
MONTH_NAME, CURRENT_DATE
HOUR, MINUTE, SECOND, ELAPSED_TIME, ADD_TIME, CURRENT_TIME
INVERSE, TRANSITIVE
Multi-Valued
Operators
Aggregates
Quantifiers
INCLUDE, EXCLUDE
AVG, SUM, COUNT, MIN, MAX
SOME, ALL, NO
Unisys
SIM Concepts:
Enterprise
Server
Division
Advanced Query Topics
Subrole Attribute (Readonly enumeration of subclasses in a class)
Retrieve the names of employees that are managers.
RETRIEVE Name of Employee
WHERE
Profession = Manager
Role Testing
Retrieve the names of employees whose spouses are managers.
RETRIEVE Name of Employee
WHERE
Spouse ISA Manager
Role Qualification
Retrieve the names of US citizens and the employee IDs of their spouses.
RETRIEVE Name of Person, Employee-ID of Spouse AS Employee
WHERE
US-Citizen
Unisys
SIM Concepts:
Enterprise
Server
Division
Advanced Query Topics
Multiple Perspective Queries (aka Joins)
Retrieve the names of project employees and managers that are the same age.
RETRIEVE Name of Project-Employee, Name of Manager
WHERE
Age of Project-Employee = Age of Manager
Reference Variables
Retrieve the names of all managers who manage employees making more than
$40,000 and employees making less than $20,000.
RETRIEVE Name of Manager
WHERE
Employee-Salary of Employees-Managing > 40000
AND
Employee-Salary of Employees-Managing CALLED Underpaid < 20000
Local Selection
Retrieve the names of managers of all departments and the salaries of only
the division managers.
RETRIEVE Name of Dept-Managers of Department,
Employee-Salary of Dept-Managers WITH
(Manager-Title of Dept-Managers = Division-Manager)
Unisys
SIM Concepts:
Enterprise
Server
Division
Update
Insert Entity: Create a new employee named John Doe and assign him to the manager named Smith.
INSERT Employee
(Name := (First-Name := “John”, Last-Name := “Doe”), Gender := Male,
Soc-Sec-No := 123-45-6789, US-Citizen := True, Employee-ID := 726478,
Spouse := Person WITH (First-Name of Name = “Mary” AND Last-Name of Name = “Doe”),
Child := INCLUDE Person WITH (First-Name of Name = “Junior” AND Last-Name of Name = “Doe”),
Employee-Manager := Manager WITH (Last-Name of Name = “Smith”)
Insert Role: Promote John Doe to department manager with a bonus of $5000.
INSERT Manager FROM Employee WHERE Last-Name of Name = “Doe”
(Manager-Title := Department-Manager, Bonus := 5000)
Modify: Reassign all Journeyman Project-Employees in the Construction Department to the Maintenance
Department.
MODIFY Project-Employee (Dept-In := Department WITH (Dept-Title = “Maintenance”))
WHERE Title = Journeyman AND Dept-Title of Dept-In = “Construction”
Delete: Remove all projects assigned to managers that manage departments located in Los Angeles.
DELETE Project
WHERE Dept-Location of Managers-Department of Project-Manager = “Los Angeles”
Unisys
SIM Example
Organization: a projects and employee database
Database descriptions
– DMS II
– DB2
A record oriented DBMS
A relational DBMS
– SIM
A semantic DBMS
Query Comparisons
– Three retrieval queries of increasing complexity
– Application program sizes
Enterprise
Server
Division
Unisys
Enterprise
Server
Division
SIM Example
Organization Basic Facts
– Employees are People
– Project-Employees are Employees who are assigned to
Projects
– Managers are Employees who manage Projects
– Sometimes a Project-Employee can act as a Manager on an
interim basis
– Projects may have Subprojects
– Historical records of Previous Employees must be retained
Unisys
SIM Example:
Family
Parent-SSN
Child-SSN
Family-Set
Education
Soc-Sec-No
Education-Set
Enterprise
Server
Division
DMS II Schema
Person
Assignment
Soc-Sec-No
Spouse-SSN
Managers-SSN
Assignment-No
Dept-No
Employed
Employee-ID
Assignment-No
Project-No
Person-Set
Interim-Manager
Assignment-Set
Project-Person
Employee-ID
Project-No
ProjPerson-Set
Project
Project-No
Dept-No
SuperProject-No
Project-Set
Employee-ID
Duration
StartDate
EndDate
InterimHist-Set
Department
Dept-No
Department-Set
Interim-Set
Legend
Data Set Name
Attributes
Primary Index
Unisys
SIM Example:
Family
Parent-SSN
Child-SSN
Education
Soc-Sec-No
Person
DB2 Schema
Assignment
Assignment-No
Project-No
Soc-Sec-No
Spouse-No
Managers-SSN
Assignment-No
Dept-No
Employed
Employee-ID
Project-Person
Interim-History
Department
Employee-ID
StartDate
EndDate
Enterprise
Server
Division
Employee-ID
Project-No
Project
Project-No
Dept-No
SuperProject-No
Dept-No
Legend
Table Name
Column Name
Enterprise
Server
Division
Unisys
SIM Example:
Organization Schema
Person
Name (First-Name, Mid-Initial, Last-Name)
Current-Residence (Street, City, State, ZipCode)
Education (Degree-Obtained, Year-Obtained, GPA) MV
Next-of-Kin (Relationship, Phone, Name-Of-Kin (First-Name, Mid_Initial, Last-Name))
Marital-Status
US-Citizen
Soc-Sec-No
Birth-Date
Gender
Age
Child
Parent
Previous-Employee
Termination-Reason
Leave-Status
Last-Work-Date Hire-Date
Project-Employee
Title
Overall-Rating
Dept-In
Employee
Employee-ID
Employee-Hire-Date
Employee-Salary
Employee-Status
Spouse
Employee-Manager
Employees-Managed
Manager
Interim-Manager
Interim-History
(Start-Date,
End-Date) MV
Manager-Title
Bonus
Dept-Staff
Project-Manager
Department
Staff-Assigned
Assignment
Start-Date AssignmentNo
End-Date Rating
Est-Person-Hours
(Next-Project-No)
Project-No
Project-Title
Project-Of
Assignment-History
Sub-Projects
Assignment-Record
Project
Dept-Assigned
Sub-Project-Of
Dept-No
Dept-Title
Dept-Location
Projects-Managing
Unisys
SIM Example:
Enterprise
Server
Division
Comparison Queries
Simple Query
Print the names of all non-managers and the title of the department in
which they work.
Complex Query
Print the names of employees and the titles of all their projects if they
work on any project assigned to the Accounting Department.
Hard Query
For the Annual Report Preparation project, print the titles of its
subprojects and the names of employees currently assigned.
Unisys
SIM Example:
Simple Query
Print the names of all non-managers and the title of the department in which they work.
DMS II
RELATE
TAB
WHERE
FROM
Person TO Department BY MATCHING Dept-No WITH Dept-No AS Person-Dept;
First-Name, Mid-Initial, Last-Name, Dept-Title
Employed NEQ “Manager”
Person TO Department;
DB2
SELECT
FROM
WHERE
AND
First-Name, Mid-Initial, Last-Name, Title
Person, Department
Person.Dept-No = Department.Dept-No
Person.Employed NEQ “Manager”;
SIM
RETRIEVE Name of Project-Employee, Dept-Title of Dept-In
Enterprise
Server
Division
Unisys
SIM Example:
Enterprise
Server
Division
Complex Query
Print the names of employees and the titles of all their projects if they work on any project
assigned to the Accounting Department.
DMS II
RELATE Department TO Project BY MATCHING Dept-No
WITH Dept-No AS Dept-Proj;
RELATE Project TO Project-Person BY MATCHING
Project-No WITH Project-No AS Proj-Person;
RELATE Project-Person TO Person BY MATCHING
Soc-Sec-No WITH Soc-Sec-No AS Proj-Emp;
EXTRACT Soc-Sec-No, COUNT AS SSN-Cnt WHERE
Dept-TItle “Accounting” FROM Person TO
Project-Person TO Project TO Department :
EXTRACTFILE = ExtFile;
OPEN FILE ExtFile;
RELATE ExtFile TO Project-Person BY MATCHING
Soc-Sec-No WITH Soc-Sec-No AS Extrel;
TAB
First-Name, Mid-Initial, Last-Name, Project-Title
FROM ExtFile TO Project-Person TO Project
WHERE SSN-Cnt > 0;
DB2
SELECT
FROM
WHERE
AND
AND
FIrst-Name, MId-Initial, Last-Name, Project-Title
Person, Project-Person, Project
Person.Soc-Sec-No = Project-Person.Soc-Sec-No
Project.Project-No = Project-Person.Project-No
EXISTS
(SELECT
*
FROM
Project-Person, Project, Department
WHERE
Project-Person.Soc-Sec-No = Person.Soc-Sec-No
AND
Project-Person.Project-No = Project.Project-No
AND
Department.Dept-No = Project.Dept-No
AND
Department.Dept-Title = “Accounting”)
SIM
RETRIEVE Name of Project-Employee, Project-TItle of Current-Project
WHERE
Dept-TItle of SOME(Dept-Assigned of Current-Project) = “Accounting”
Unisys
SIM Example:
Enterprise
Server
Division
Hard Query
For the Annual Report Preparation project, print the titles of its subprojects and the names
of employees currently assigned.
DMS II
OPEN DMSII Oranization;
OPEN DMSII OrgCopy (DMI =DMINTERPRETER/ORGANIZATION);
RELATE Project of Organization TO Project of OrgCopy BY
MATCHING Project-No WITH SuperProject-No AS
SubProj;
RELATE Project of Organization TO Person of OrgCopy BY
MATCHING Project-No WITH Project-No AS
Project-Emp;
RELATE Project-Person of OrgCopy TO Person of OrgCopy
BY MATCHING Employee-ID WITH Employee-ID
AS Proj-Person;
TAB
Project-Title of Project of OrgCopy, First-Name of
Person of OrgCopy, Mid-Initial of Person of
OrgCopy, Last-Name of Person of OrgCopy
FROM Project of Organization TO Project of OrgCopy TO
Project-Person of OrgCopy TO Person of OrgCopy
WHERE Project-Title of Project of Organization =
“Annual Report Preparation”
DB2
SELECT
FROM
WHERE
AND
AND
AND
Project-Title, First-Name, Mid-Initial, Last-Name
Project, Project, SubProj, Person, Project-Person
Project.Project-No = SubProj.SuperProject-No
SubProj.Project-No = Project-Person.Project-No
Project-Person.Soc-Sec-No = Person.Soc-Sec-No
Project.Project-Title = “Annual Report Preparation”
SIM
RETRIEVE Project-Title of Sub-Projects of Project, Name of Project-Team of Sub-Projects
WHERE
Project-Title of Project = “Annual Report Preparation”
Unisys
Enterprise
Server
Division
Unisys is a registered trademark of Unisys Corporation.
All other brand or product names are trademarks or registered
trademarks of their respective companies.
Unisys
Unisys
Enterprise
Server
Division
Download