Semantic Object Modeling: Tutorial [Class 9.1] Overview Spring 2014

advertisement
Semantic Object Modeling:
Tutorial [Class 9.1]
Spring 2014
Overview
• Homework #6 A. and B. Bonus
– TableDesigner; Semantic Object Models (SOM)
• Starting TableDesigner
– Creating Domains and Objects
• Semantic Object Links (SOL)
– Relationships and Cardinalities
• Printing Options: SOM or Object Report
• SQL Server Model Creation
– Model Locations
• ACCESS database Model Creation
– Touchups: Define Primary Keys
1
Homework #6 Links
Resources on Website:
• Homework #6 Assignment
– For 10 point BONUS
• Becker’s 4660 Website Links:
– Time 2008-2013 Table (.mdb file)
– SOM Appendix E; SOM Tutorial
– TableDesigner: DB Design tool (FREE
software)
Starting TableDesigner
• Open TableDesigner
from COBA Course
menu (BCIS 4620
Applications)
• Select :File/New
Model
• Try Browse for
available options
• Select :Generic
2
Expand all Windows
Model Workspace
Predefined Domains
1. Objects
2. Data Items
3. Groups
:Create/Domains (F3)
3
Create Semantic Objects
:Windows/Arrange Workspace
4
Add Attributes to Objects
1. Drag & drop Primary Key (**) text type
2. Open properties menu. Right click.
Customize Attributes
1.
2.
3.
4.
Change name
Adjust cardinalities
Data Length
Domain type
5
Create New Group ID
• Build Group ClassID
– Concatenated key
– Select Data Items for
components of key
– Rename existing items
or create new items
Customized ClassID
6
Standalone Simple Objects
Semantic Object Links (SOL)
1. Drag & drop each Semantic Object to its related object(s)
2. Note: SOL appears in both objects simultaneous
7
Adjust Cardinalities of Each SOL
Item Properties dialog box
Many-to-many relationship
1. Set minimum required
2. Set maximum required
Cardinalities Adjusted
Change Data Item Names in accordance with
User preferences
8
Print SOM Model & Objects
Drop down File Menu:
Print options (Ctrl-P)
Print Model Information:
Objects
Semantic Object Report
Page 1: College Object
Page 2: Department
Object
1 Page for each SO; Suggest. Print 2 per page when possible
9
Save SOM Model Prior to
Generating ACCESS Database (.mdb)
• :Save/”name”
• Select directory
location
• UNTCOBA.apm
• :File/Print… [SOM
Diagram]
• :File/Print Model
Information/Objects…
:Options/File Locations…
10
Create SQLGen.txt file
• :Create/SQL Text
Only…
• Change ODBC Driver
option to “SQL
Server” database
• Select “Generate”
when prompted to
save model again
• Next screen VERY
IMPORTANT!
• See next page
SQLGen.txt Code Generation
------------------< SQL Statements >----------------------- Schema Name:
-- Time
: Wed Mar 30 22:13:11 200X
SET ANSI_WARNINGS OFF;
CREATE TABLE COLLEGE(
CollegeName varchar(15) NOT NULL,
Address_Street varchar(30) NULL,
Address_City varchar(35) NULL,
Address_State varchar(2) NULL,
Address_Zip varchar(5) NULL);
Partial file listing
ALTER TABLE COLLEGE
ADD
CONSTRAINT PRM5660 PRIMARY KEY ( CollegeName )
;
CREATE TABLE DEPARTMENT(
DepartmentName varchar(15) NOT NULL,
MailingAddress_Street varchar(30) NULL,
MailingAddress_City varchar(35) NULL,
MailingAddress_State varchar(2) NULL,
MailingAddress_Zip varchar(5) NULL,
CatalogAddress_BuildingName varchar(30) NULL,
CatalogAddress_RoomNumber varchar(5) NULL,
COLLEGE_CollegeName_FK varchar(15) NULL);
11
SQLGen.txt Code Generation
CREATE TABLE CLASSES(
ID_ int NOT NULL,
ClassID_ClassCode varchar(8) NULL,
ClassID_SectionID tinyint NULL,
ClassID_SemesterCode datetime NULL,
Name varchar(25) NULL,
Description text NULL,
DEPARTMENT_DepartmentName_FK varchar(15) NULL,
PROFESSOR_ProfessorID_FK int NULL);
Partial file listing
Foreign Key
Classes:Department
ALTER TABLE CLASSES
ADD
CONSTRAINT PRM5658 PRIMARY KEY ( ID_ )
;
CREATE INDEX IDX5668 ON CLASSES(ClassID_ClassCode);
CREATE INDEX IDX5693 ON CLASSES(Name);
CREATE TABLE STUDENT_CLASSES_X(
STUDENT_StudentID_FK int NOT NULL,
CLASSES_ID_FK int NOT NULL);
Intersection Table
Student:Classes
ALTER TABLE STUDENT_CLASSES_X
ADD
CONSTRAINT PRM5709 PRIMARY KEY ( STUDENT_StudentID_FK, CLASSES_ID_FK )
;
Next Create Access Database
• :Create/Database
(F2)
• Select “Yes” when
prompted to save
model again
• Next screen VERY
IMPORTANT!
• See next page
Note: When copying .apm file from
One physical PC directory to another,
save a new copy of the model WITHOUT
Database Model “attachments”
12
Make Sure All Settings are
Correct
Database settings
For ACCESS database
:Options/Default Database
Type
13
:Options/Default Database Type
Configure…/Modify…/OK
Reassigned to Flash Drive G:
14
UNTCOBA Access Database
• Look inside You Assigned DB directory for the
.mdb Access database file. OPEN!
Entity Relationship Diagram
15
Preliminary Database Design:
Touchups
• Customize Access Database
– Adjust Attribute Names
• Note: Attributes with MixedCaseNames will
generate names like Mixed_Case_Names
– Underscores will be inserted in front of Capital letters.
– Set Your own Primary Keys
• _ID keys added to all tables may be deleted or
redefined in TableDesigner
:Edit/Primary Key Settings
16
Most Keys Adjusted
Except Classes
Changing Primary Key in Class
17
Convert to Star Diagram(s)
• Identify Dimension
and Fact Tables
• Add Time
Dimension(s)
• Group metrics and
facts by time periods
–
–
–
–
Yearly
Monthly
Weekly
Daily, etc.
• Modify ERD as
required
• Reassess primary
and foreign key
relationships
• Populate tables with
records
• Compute and store
subtotals
Star Diagram: Conformed Tables
Dimension & Fact “columns”
Time/Date
Rep
Invoice Facts
Customer
[Order No.]
Territory
Payment Facts
Part
[Invoice No.]
Vendor
Order Facts
Invoice-Order
-Payments
Key Table
Vendor Part
[Order No.]
[Logical Table]
18
Summary
• SOM Database Design Tool
– Build SO Model
– Create SQL CREATEs
– Create ACCESS database
– Modify ACCESS Relationship Diagram
• Convert to Star Schema
– Use ACCESS database as a starting point
19
Download