7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 1/42
Dr. Philip Cannata 1
SIM Data Model and ReL
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 2/42
Dr. Philip Cannata 2
Semantic Data Models
2/88
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 3/42
Dr. Philip Cannata 3
Doug Tolbert
Doug Tolbert has been involved with OMG since the early 1990s. He is a member of the Board of
Directors and currently holds a Platform seat on the Architecture Board. Doug was a principal
member of the team that developed CWM, and he has made contributions to many OMG platform
(UML, MOF, XMI, IMM, SOA, Alf, and ADTF) and domain (Finance, Life Science, Insurance) over
the years. He is currently active on the UML Simplification and IMM submission teams. On the AB,
Doug works to ensure that OMG specifications are clear and understandable in both their human- and
machine-readable forms.
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 4/42
Dr. Philip Cannata 4
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 5/42
Dr. Philip Cannata 5
SIM Example: Organization Schema
Person
Project-Employee Manager
Department
Assignment
EmployeePrevious-Employee
SpouseChild
Parent
Employee-Manager
Employees-Managed
Projects-ManagingProject-Manager
Dept-Assigned
Project-Of
Assignment-HistoryStaff-Assigned
Assignment-Record
Dept-Staff Dept-In
Interim-Manager
Start-Date Assignment-No
End-Date Rating
Est-Person-Hours
S u b -P r o j e c t s
S u b -P r o j e c t - Of
Project(Next-Project-No)Project-NoProject-Title
Manager-TitleBonus
Interim-History(Start-Date,
End-Date) MV
Employee-IDEmployee-Hire-Date
Employee-SalaryEmployee-Status
Dept-NoDept-TitleDept-Location
TitleOverall-Rating
Termination-ReasonLeave-StatusLast-Work-Date Hire-Date
Name (First-Name, Mid-Initial, Last-Name)Current-Residence (Street, City, State, ZipCode)Education (Degree-Obtained, Year-Obtained, GPA) MVNext-of-Kin (Relationship, Phone, Name-Of-Kin (First-Name, Mid_Initial, Last-Name))Marital-Status US-Citizen Soc-Sec-NoBirth-Date Gender Age
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 6/42
Dr. Philip Cannata 6
SIMOrigins and Evolution
Doug Tolbert
Unisys Corporation
Mission Viejo, CA
Unisys Server Enterprise
Division
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 7/42Dr. Philip Cannata 7
SIM Motivations: Objectives (1983)
Ease of Use
Productivity
Data Integrity
Coexistence
Performance
• Integrated, high level interface
• Query & schema flexibility
• Data Independence
• Set-oriented, non-procedural
interface
• Naturally handle complexity
• Easy to learn
• Minimal programming effort
• Retrieval without programming
• System enforced integrity
• Shared data definitions
• Referential integrity
• No impact on DMS II customer
base
• New capabilities for existingdata
• Must support production level
transaction processing systems
• Fast
• Fast
• Fast
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 8/42Dr. Philip Cannata 8
SIM Motivations: Options (1983)
Enhance DMS
II
Relational System Something New
• Improve ease of use
• Gain productivity &
data integrity without
sacrificing installed
base
• Performance thought
to be near
architectural limits
(but wasn’t true!)
• Not likely to expand
customer base
• Ease of use would
improve
• Productivity gains
marginal• Data integrity very
limited
• Extensive data
engine rework
•
No migration path for customer base
• Performance?
• Late to market
• 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
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 9/42Dr. Philip Cannata 9
SIM: Something New!
Artificial Intelligence
Semantic NetworksQuillian, Brachman
SIMGraphical Data Models
Entity RelationshipChen
Set Data Models
RM/TCodd
Query Languages
GORDASEl-Masri
Semantic Models
SDMHammer & McLeod
Programmatic Model
DAPLEXShipman
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 10/42Dr. Philip Cannata 10
SIM: A Semantic Data Model
What makes a data model“semantic”?
“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. Thisactivity 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
• SDMs capture the meaning of data,
not just its physical representation
• So, the more meaning a data model
captures, the more “semantic” it is
How does a semantic data modelcapture meaning?
“... 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 databasedesigner to construct and modify than one
that forces him to translate the primitives of
his problem domain into artificial
specification construction.”
-- Hammer & McLeod, 1981
• Schema objects should look likecorresponding real world objects
• Meaning captured by object types,
relationships, attribute types,
cardinality constraints, active rules
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 11/42Dr. Philip Cannata 11
SIM Concepts: Entities & Attributes
Entity An object or idea of interest in the
application environment
Does not imply a particular physicalimplementation
But functional analogs are recordsand 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 employeeID, a salary, ...
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 12/42Dr. Philip Cannata 12
SIM Concepts: Classes & Subclasses
Class A collection of entities of the
same type
Employee, the set of allemployees working for acompany
Subclass A subset of entities in a class
Project-Employees are
employees that work onprojects
Employee
Project-Employee
ISA
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 13/42Dr. Philip Cannata 13
SIM Concepts: Attributes
Attribute Inheritance
Subclasses inherit attributes from
all their superclasses
Subclasses may declare additional
attributes
Attribute Types
Data-Valued Attributes (DVA)
Have a printable value
Entity-Valued Attributes (EVA)
Entities in another class
Model relationships
Employee Name EmployeeID
Project-EmployeeTitle
Department
Dept- I n
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 14/42Dr. Philip Cannata 14
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
Extended Attributes
Attributes of related entities
may be considered
extended attributes of theperspective class
Employee Name
EmployeeID
Project-EmployeeTitle
Department Dept-No
Dept-
I
n
Dept-No of Dept-In of Project-Employee = 123
Dept-No of Department = 123
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 15/42Dr. Philip Cannata 15
SIM Concepts: Constraints & Relations
Attribute ConstraintsIsomorphic for EVA/DVA
Single-Valued
Multi-Valued
RequiredUnique
Relationships (EVAs)
Always bi-directional
Automatic referential integrity
Transitive closure function
Employee Name
EmployeeID
Project-EmployeeTitle
Department Dept-No
Dept-
I
n
Title of INVERSE(Dept-In) of Department
Title of Dept-Staff of Department
Dept-Staff
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 16/42Dr. Philip Cannata 16
SIM Concepts: 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 User Defined
• Integer
• Real
• Boolean
• Date
• Time
• Character
• 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)
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 17/42Dr. Philip Cannata 17
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 NoCouples ON Employee
ASSERT Not (Spouse ISA Employee)
WHERE Employee-Hire-Date > 12/31/95
ELSE “Spouse may not work for company”
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 18/42Dr. Philip Cannata 18
SIM Concepts: 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 LookButDontTouch ON Employee (Employee-Salary)
RETRIEVE
WHERE Employee-Status >= Journeyman
PERMISSION USERCODE = Accounting, ACCESS = LookButDontTouch
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 19/42
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 20/42Dr. Philip Cannata 20
SIM Concepts: Expressions
OperatorsArithmetic +, -, *, /, DIV, MOD, **Boolean NOT, AND, OR Relational <, >, =, <=, >=, <>String &, pattern matchingExistence EXISTS
FunctionsArithmetic ABS, ROUND, TRUNC, SQRTString LENGTH, EXT, POS, RPTSymbolic PRED, SUCCDate YEAR, MONTH, DAY, ELAPSED_DAYS, ADD_DAYS, DAY_OF_WEEK,
MONTH_NAME, CURRENT_DATETime HOUR, MINUTE, SECOND, ELAPSED_TIME, ADD_TIME, CURRENT_TIMERelationships INVERSE, TRANSITIVE
Multi-ValuedOperators INCLUDE, EXCLUDEAggregates AVG, SUM, COUNT, MIN, MAXQuantifiers SOME, ALL, NO
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 21/42Dr. Philip Cannata 21
SIM Concepts: Advanced Query Topics
Subrole Attribute (Readonly enumeration of subclasses in a
class)
Role Testing
Role Qualification
Retrieve the names of employees that are managers. RETRIEVE Name of EmployeeWHERE Profession = Manager
Retrieve the names of employees whose spouses are managers. RETRIEVE Name of EmployeeWHERE Spouse ISA Manager
Retrieve the names of US citizens and the employee IDs of their spouses. RETRIEVE Name of Person, Employee-ID of Spouse AS EmployeeWHERE US-Citizen
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 22/42Dr. Philip Cannata 22
SIM Concepts: Advanced Query Topics
Multiple Perspective Queries (aka Joins)
Reference Variables
Local Selection
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
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 > 40000AND Employee-Salary of Employees-Managing CALLED Underpaid < 20000
Retrieve the names of managers of all departments and the salaries of onlythe division managers. RETRIEVE Name of Dept-Managers of Department,
Employee-Salary of Dept-Managers WITH(Manager-Title of Dept-Managers = Division-Manager)
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 23/42
Dr. Philip Cannata 23
SIM Concepts: 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 MaintenanceDepartment.
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 ProjectWHERE Dept-Location of Managers-Department of Project-Manager = “Los Angeles”
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 24/42
Dr. Philip Cannata 24
SIM Example
Organization: a projects and employee database
Database descriptions
DMS II A record oriented DBMS
DB2 A relational DBMSSIM A semantic DBMS
Query Comparisons
Three retrieval queries of increasing complexity
Application program sizes
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 25/42
Dr. Philip Cannata 25
SIM Example
Organization Basic FactsEmployees 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
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 26/42
Dr. Philip Cannata 26
SIM Example: DMS II Schema
Soc-Sec-NoSpouse-SSNManagers-SSNAssignment-NoDept-NoEmployedEmployee-ID
Person
Person-Set Employee-IDProject-No
Project-Person
ProjPerson-Set
Soc-Sec-No
Education
Education-Set
Assignment-NoProject-No
Assignment
Assignment-Set
Dept-No
Department
Department-Set
Parent-SSNChild-SSN
Family
Family-Set
Employee-ID
Interim-Manager
Interim-Set
StartDate
EndDate
Duration
InterimHist-Set
Project-NoDept-NoSuperProject-No
Project-Set
Project
Attributes
Data Set Name
Primary Index
Legend
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 27/42
Dr. Philip Cannata 27
SIM Example: DB2 Schema
Soc-Sec-NoSpouse-NoManagers-SSNAssignment-No
Dept-NoEmployedEmployee-ID
Person
Soc-Sec-No
Education
Assignment-NoProject-No
Assignment
Dept-No
Department
Parent-SSNChild-SSN
Family
Project-NoDept-NoSuperProject-No
Project
Employee-IDStartDateEndDate
Interim-History
Employee-IDProject-No
Project-Person
Column Name
Table Name
Legend
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 28/42
Dr. Philip Cannata 28
SIM Example: Organization Schema
Person
Project-Employee Manager
Department
Assignment
EmployeePrevious-Employee
SpouseChild
Parent
Employee-Manager
Employees-Managed
Projects-ManagingProject-Manager
Dept-Assigned
Project-Of
Assignment-HistoryStaff-Assigned
Assignment-Record
Dept-Staff Dept-In
Interim-Manager
Start-Date Assignment-No
End-Date Rating
Est-Person-Hours
S u b -P r o j e c t s
S u b -P r o j e c t - Of
Project(Next-Project-No)Project-NoProject-Title
Manager-TitleBonus
Interim-History(Start-Date,End-Date) MV
Employee-IDEmployee-Hire-DateEmployee-Salary
Employee-Status
Dept-NoDept-TitleDept-Location
TitleOverall-Rating
Termination-ReasonLeave-StatusLast-Work-Date Hire-Date
Name (First-Name, Mid-Initial, Last-Name)Current-Residence (Street, City, State, ZipCode)Education (Degree-Obtained, Year-Obtained, GPA) MVNext-of-Kin (Relationship, Phone, Name-Of-Kin (First-Name, Mid_Initial, Last-Name))Marital-Status US-Citizen Soc-Sec-NoBirth-Date Gender Age
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 29/42
Dr. Philip Cannata 29
SIM Example: 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.
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 30/42
Dr. Philip Cannata 30
SIM Example: Simple Query
DMS II
RELATE Person TO Department BY MATCHING Dept-No WITH Dept-No AS Person-Dept;TAB First-Name, Mid-Initial, Last-Name, Dept-TitleWHERE Employed NEQ “Manager ” FROM Person TO Department;
DB2
SELECT First-Name, Mid-Initial, Last-Name, TitleFROM Person, DepartmentWHERE Person.Dept-No = Department.Dept-NoAND Person.Employed NEQ “Manager ”;
SIM
RETRIEVE Name of Project-Employee, Dept-Title of Dept-In
Print the names of all non-managers and the title of the department in which they work.
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 31/42
Dr. Philip Cannata 31
SIM Example: Complex Query
DMS II
RELATE Department TO Project BYMATCHING Dept-NoWITH Dept-No AS Dept-Proj;
RELATE Project TO Project-Person BYMATCHINGProject-No WITH Project-No AS Proj-Person;
RELATE Project-Person TO Person BYMATCHINGSoc-Sec-No WITH Soc-Sec-No AS Proj-Emp;
DB2SELECT FIrst-Name, MId-Initial, Last-Name, Project-TitleFROM Person, Project-Person, ProjectWHERE Person.Soc-Sec-No = Project-Person.Soc-Sec-NoAND Project.Project-No = Project-Person.Project-NoAND EXISTS (SELECT *
FROM Project-Person, Project, DepartmentWHERE Project-Person.Soc-Sec-No = Person.Soc-Sec-No
AND Project-Person.Project-No = Project.Project-NoAND Department.Dept-No = Project.Dept-NoAND Department.Dept-Title = “Accounting”)
SIM
RETRIEVE Name of Project-Employee, Project-TItle of Current-ProjectWHERE Dept-TItle of SOME(Dept-Assigned of Current-Project) = “Accounting”
Print the names of employees and the titles of all their projects if they work on any projectassigned to the Accounting Department.
EXTRACT Soc-Sec-No, COUNT AS SSN-Cnt WHEREDept-TItle “Accounting” FROM Person TOProject-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-Tit leFROM ExtFile TO Project-Person TO ProjectWHERE SSN-Cnt > 0;
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 32/42
Dr. Philip Cannata 32
SIM Example: Hard Query
DMS II
OPEN DMSII Oranization;OPEN DMSII OrgCopy (DMI
=DMINTERPRETER/ORGANIZATION);
RELATE Project of Organization TO Project of OrgCopyBYMATCHING Project-No WITH SuperProject-NoASSubProj;
RELATE Project of Organization TO Person of OrgCopyBYMATCHING Project-No WITH Project-No ASProject-Emp;
DB2
SELECT Project-Title, First-Name, Mid-Initial, Last-NameFROM Project, Project, SubProj, Person, Project-PersonWHERE Project.Project-No = SubProj.SuperProject-No
AND SubProj.Project-No = Project-Person.Project-NoAND Project-Person.Soc-Sec-No = Person.Soc-Sec-NoAND Project.Project-Title = “Annual Report Preparation”
SIM
RETRIEVE Project-Title of Sub-Projects of Project, Name of Project-Team of Sub-ProjectsWHERE Project-Title of Project = “Annual Report Preparation”
For the Annual Report Preparation project, print the titles of its subprojects and the namesof employees currently assigned.
RELATE Project-Person of OrgCopy TO Person of OrgCopyBY MATCHING Employee-ID WITH Employee-IDAS Proj-Person;
TAB Project-Tit le 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 TOProject-Person of OrgCopy TO Person of OrgCopyWHERE Project-Title of Project of Organization =
“Annual Report Preparation”
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 33/42
Dr. Philip Cannata 33
mgr
SIM - Semantic Data Management
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 34/42
Dr. Philip Cannata 34
CLASS person
( ss_num: INTEGER, REQUIRED;
name: STRING;);
SUBCLASS emp OF person
( job : STRING;
mgr : emp, SV, INVERSE IS employees;
sal : INTEGER;
comm : INTEGER;
dept : dept, SV, INVERSE IS employees;
);
CLASS dept
( deptno : INTEGER, REQUIRED;
dname : STRING;
loc : STRING;
employees : emp, MV, INVERSE IS dept;
);mgr
SIM - Semantic Data Management
CLASS
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 35/42
Dr. Philip Cannata 35
CLASS person
(
ss_num: INTEGER, REQUIRED;
name: STRING;
);
SUBCLASS emp "Employees of a company" OF person
(
job : STRING;
mgr : emp, SV, INVERSE IS employees;
employees : emp, MV, INVERSE IS mgr;
sal : INTEGER;
comm : INTEGER;
dept : department, SV, INVERSE IS employees;);
INSERT emp ( ss_num:= 7369 , name := "SMITH" , job := "CLERK" , sal := 800 );
INSERT emp ( ss_num:= 7499 , name := "ALLEN" , job := "SALESMAN" , sal := 1600 , comm := 300 );
INSERT emp ( ss_num:= 7521 , name := "WARD" , job := "SALESMAN" , sal := 1250 , comm := 500 );
INSERT emp ( ss_num:= 7566 , name := "JONES" , job := "MANAGER" , sal := 2975 );
INSERT emp ( ss_num:= 7654 , name := "MARTIN" , job := "SALESMAN" , sal := 1250 , comm := 1400 );
INSERT emp ( ss_num:= 7698 , name := "BLAKE" , job := "MANAGER" , sal := 2850 );INSERT emp ( ss_num:= 7782 , name := "CLARK" , job := "MANAGER" , sal := 2450 );
INSERT emp ( ss_num:= 7788 , name := "SCOTT" , job := "ANALYST" , sal := 3000 );
INSERT emp ( ss_num:= 7839 , name := "KING" , job := "PRESIDENT" , sal := 5000 );
INSERT emp ( ss_num:= 7844 , name := "TURNER" , job := "SALESMAN" , sal := 1500 );
INSERT emp ( ss_num:= 7876 , name := "ADAMS" , job := "CLERK" , sal := 1100 );
INSERT emp ( ss_num:= 7900 , name := "JAMES" , job := "CLERK" , sal := 950 );
INSERT emp ( ss_num:= 7902 , name := "FORD" , job := "ANALYST" , sal := 3000 );
INSERT emp ( ss_num:= 7934 , name := "MILLER" , job := "CLERK" , sal := 1300 );
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 36/42
Dr. Philip Cannata 36
CLASS department "Departments of a company"(
deptno : INTEGER, REQUIRED;
dname : STRING;
loc : STRING;
employees : emp, MV, INVERSE IS dept;
);
INSERT department ( deptno := 10 , dname := "ACCOUNTING" , loc := "NEW YORK" );
INSERT department ( deptno := 20 , dname := "RESEARCH" , loc := "DALLAS" );
INSERT department ( deptno := 30 , dname := "SALES" , loc := "CHICAGO" );
INSERT department ( deptno := 40 , dname := "OPERATIONS" , loc := "BOSTON" );
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 37/42
Dr. Philip Cannata 37
MODIFY emp ( dept := department WITH (deptno = 20) ) WHERE ss_num = 7369 ;
MODIFY emp ( dept := department WITH (deptno = 30) ) WHERE ss_num = 7499 ;
MODIFY emp ( dept := department WITH (deptno = 30) ) WHERE ss_num = 7521 ;
MODIFY emp ( dept := department WITH (deptno = 20) ) WHERE ss_num = 7566 ;
MODIFY emp ( dept := department WITH (deptno = 30) ) WHERE ss_num = 7654 ;
MODIFY emp ( dept := department WITH (deptno = 30) ) WHERE ss_num = 7698 ;MODIFY emp ( dept := department WITH (deptno = 10) ) WHERE ss_num = 7782 ;
MODIFY emp ( dept := department WITH (deptno = 20) ) WHERE ss_num = 7788 ;
MODIFY emp ( dept := department WITH (deptno = 10) ) WHERE ss_num = 7839 ;
MODIFY emp ( dept := department WITH (deptno = 30) ) WHERE ss_num = 7844 ;
MODIFY emp ( dept := department WITH (deptno = 20) ) WHERE ss_num = 7876 ;
MODIFY emp ( dept := department WITH (deptno = 30) ) WHERE ss_num = 7900 ;
MODIFY emp ( dept := department WITH (deptno = 20) ) WHERE ss_num = 7902 ;MODIFY emp ( dept := department WITH (deptno = 10) ) WHERE ss_num = 7934 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7902) ) WHERE ss_num = 7369 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7698) ) WHERE ss_num = 7499 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7698) ) WHERE ss_num = 7521 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7839) ) WHERE ss_num = 7566 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7698) ) WHERE ss_num = 7654 ;MODIFY emp ( mgr := emp WITH (ss_num = 7839) ) WHERE ss_num = 7698 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7839) ) WHERE ss_num = 7782 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7566) ) WHERE ss_num = 7788 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7698) ) WHERE ss_num = 7844 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7788) ) WHERE ss_num = 7876 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7698) ) WHERE ss_num = 7900 ;
MODIFY emp ( mgr := emp WITH (ss_num = 7566) ) WHERE ss_num = 7902 ;MODIFY emp ( mgr := emp WITH (ss_num = 7782) ) WHERE ss_num = 7934 ;
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 38/42
Dr. Philip Cannata 38
WDB> from person retrieve * where true;
WDB> from emp retrieve * where true;
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 39/42
Dr. Philip Cannata 39
WDB> from emp retrieve * where true; WDB> from department retrieve * where true;
WDB> from emp retrieve *, * of dept where true;
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 40/42
Dr. Philip Cannata 40
WDB> from emp retrieve ss_num, name, dname of dept, name of mgr, dname of dept of mgr
where true;
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 41/42
Dr. Philip Cannata 41
with ReL
7/28/2019 10 SIM and ReL
http://slidepdf.com/reader/full/10-sim-and-rel 42/42
ReL Components
Python.g
SPARQLDoer.java
PyTuple.java------------ parseSIM()
AST
Runtime Stack
SIMHelper.java
Visitor
SQLVisitor.java
jSQLParser
Interpreter
jSIMParser
CodeCompiler.java
The Python grammar waschanged to include SIM, SQL,
Prolog, and ASP statements.
The Tuple entry in
CodeCompiler was
modified to deal with putting SIM, SQL, Prolog,
and ASP information and
expressions on the runtime
stack and to assure that a
new instance of PyTuple is
created after the
expressions are evaluated.
jSQLParser parses SQL
statements from PyTuple and
produces an AST that can be
visited.
SQLVisitor visits the
jSQLParser AST and
produces appropriate
SPARQL statements for the
parseSIM parses SIM
statements from PyTuple and
produces and passes AS
information to SIMHelper.
SIMHelper produces
appropriate SPARQL
statements for the SIM
statements which are sent to
SPARQLDoer.
There is no jSIMParser to
parse SIM statements like
jSQLParser for SQL but I
hope one will be built as a
project.