PPTX

advertisement
Chapter 4 & 5 6e - 8 5e: More SQL DDL
CSE
4701
Prof. Steven A. Demurjian, Sr.
Computer Science & Engineering Department
The University of Connecticut
191 Auditorium Road, Box U-155
Storrs, CT 06269-3155
steve@engr.uconn.edu
http://www.engr.uconn.edu/~steve
(860) 486 - 4818


About one third of these slides are being used with the permission of Dr. Ling
Lui, Associate Professor, College of Computing, Georgia Tech.
About one-half of these slides have been adapted from the AWL web site for
the textbook.
Chaps 4&51
SQL DDL - Case Study

CSE
4701


Let’s Explore a Case Study of Ongoing Work Between
 State of Connecticut Insurance Department
 CS&E at UConn (Demurjian/Shin et al.)
This Project has Been Underway since 1999
Objective is to Replace and Modernize Computing
 Currently Using Wang Mini Computer
 PCs with Terminal Emulator Type Interface
 COBOL
 Proprietary Non-Relational Database
 1980s Technology
Chaps 4&52
What Does CT Insurance Department Do?

CSE
4701


Regulatory Agency for Insurance Industry
Major Responsibilities Include:
 Licensing Agents, Companies, Agencies
 Monitoring Behavior of Licensees
 Serving as an Advocate for Consumer
 Processing Complaints Against Licensees
Consists of Multiple Divisions, Including:
 Licensing
 Consumer Affairs
 Life& Health, Property & Casualty
 Examinations, Market Conduct, etc.
Chaps 4&53
Complaint Master File

CSE
4701
Current Back End- Wang Proprietary Software with
Interfaces to MS-DOS-Screens (COBOL)
Chaps 4&54
Data Entry Screen for New Complaint
CSE
4701
Chaps 4&55
Result of Entering Complainant
CSE
4701
Chaps 4&56
Licensing - Software Structure
CSE
4701
Initial Data
Entry Operator
(Scanning &
Posting)
Advanced Data
Entry
Operators
Analyst
Manager
10-100MB Network
Document
Server
Stored
Images/CD
Database
Server
Running
Oracle
Access to
External
Databases
NAIC
Chaps 4&57
Licensing: Scanning/Data Entry
CSE
4701
DB
DB
Historical Completed
Records Applications
Licensing
DB
Supervisor
Review
Scanner
DB
Licensing
Division
Scanning
Operator
Stored
Images
Licensing Division Printer
Data Entry Operator
DB
Basic
Information
Entered
New Licenses
New Appointments
FOI
Letters (Request
Information, etc.)
Chaps 4&58
Utilizing the Work Queue
CSE
4701
Next License Application
Issue New License
New License
Application
Work Queue
Issue Rejection Letter
Operator
Supervisor Work Queue
Requests Next License
Application in Work Queue
Chaps 4&59
Licensing Capabilities and Tasks

CSE
4701

Scanning Business Process
 Scan Documents and Enter Basic Information
 Verify Readability of Scanned Documents
 Scanned Documents Automatically Enter a Work
Queue for Subsequent Processing
 Create Historical Record for Each Action of
Scanning Personnel
Historical Record Allows:
 Tracking Productivity by Examining Who Scanned
Which Documents
 Ability to Provide History of Application, License,
etc., when Processing Question from Agent, FOI
Request, etc.
Chaps 4&510
Licensing Capabilities and Tasks

CSE
4701


Processing Work Queue Elements Which Contain:
 License Applications
 Documents Requested by Insurance Dept.
 Appointments/Re-appointments
 FOI Requests, etc …
Each Work Queue Element Contains One or More
Scanned Images to be Processed
Result of Processing
 Modify Historical Record
 Create Entry in Oracle Database
 Document Sent to CD-Rom Repository
 Errors/Problems Forwarded to Analyst
Chaps 4&511
Consumer Affairs - Software Structure
CSE
4701
Initial Data
Entry Operator
(Scanning)
Clerical
Operator
Chief
Examiner
Examiner
10-100MB Network
FileNet
Server
Stored
Documents
Database
Server
Running
Oracle
Access to
External
Databases
MVD DB
Chaps 4&512
Consumer Affairs: Scanning/Data Entry
CSE
4701
Oracle
Complaints, Letters,
Responses, etc.
Scanner
Filenet
Consumer
Affairs
Division
Scanning
Operator
Basic
Information
Stored
Images
Oracle
Oracle
Historical Documents to
Records be Processed
Sorting by
Examiner
Data
Entry
New
Complaints
Data Entry
by CA
Clerical
Processing by
Examiners
Generated
Letters
Chaps 4&513
Consumer Affairs Capabilities and Tasks

CSE
4701



Scanning Similar to Licensing
Classification/Assignment
 New Complaints are Classified and Assigned to
Examiners
 Existing Complaints are Matched to Examiners
Processing
 Each Complaint Must Proceed Through Stages
 Open, Processing, Review, Closing
 Can take from Days to Months or Longer
FOI Requests
 Request by Public (Typically Lawyers) for
Information of Complaints
 Against Agents, Companies, Agencies
Chaps 4&514
Wang Database Design/Content

CSE
4701


Wang System has a Complete Database Design
(Network Data Model) for Current Functionality
Design is Poorly Structured
 No Key’s; No Referential Integrity
 Data Checking on Fields not Supported
Database Repository has Lots of Null Values
 Licensees with Same License Numbers
 Inconsistencies Across Database (License Names
spelled differently in different locations, etc.)
 Data Fields used as Placeholders for Different
Reasons
Chaps 4&515
Database Design

CSE
4701

From a Database Design Perspective, Intent was to
Transition from
 Non-Relational, Poorly Designed, mid-80s Solution
 Fully Relational, Well Designed Modern Solution
Issues:
 5 Major Divisions (Licensing, Consumer Affairs,
Market Conduct, Life&Health, Property&Casualty)
 Limited Development Staff
 Major Requirements Definition for Modern Solution
 Need a Plan to Transition Incrementally
 Adopt a Multi-Year Process
Chaps 4&516
ER-Like Diagram for Licensing
CSE
4701
Notes:
See Links to Entities on Next Slide
Many Attributes have been Omitted
Chaps 4&517
ER-Like Diagram for Licensing
CSE
4701
Chaps 4&518
Licensing Tables

CSE
4701
As Presented, Not all Attributes Shown – only
 Keys, Foreign Keys, Indexes, etc.
CREATE TABLE Individual
(
Ind_SSN Number(9) NOT NULL, Ind_Last_Name VarChar(30),
Ind_First_Name VarChar(30), Ind_Middle_Name VarChar(30),
Ind_Title VarChar(10), Ind_DBA_Name VarChar(100),
Ind_Resident Char(2), Ind_Status Char(2), Ind_CE Char(1),
Ind_Birth_Date Date, Ind_Complaints Number(5),
Ind_Appointments Number(5), Ind_Org_Designations Number(5),
Ind_LTC_Partnership Char(1), Ind_LTC_Date Date,
Ind_LTC_Course VarChar(50), Ind_FEIN1 Number(9),
Ind_FEIN2 Number(9), Ind_NIPR Number(10),
Ind_Comments VarChar(2000),
CONSTRAINT PK_Individual PRIMARY KEY (Ind_SSN),
CONSTRAINT FK_Ind_Resident FOREIGN KEY (Ind_Resident)
REFERENCES Resident(RE_Resident),
CONSTRAINT FK_Ind_Status FOREIGN KEY (Ind_Status)
REFERENCES I_O_Status(IS_Status),
CONSTRAINT FK_Ind_CE FOREIGN KEY (Ind_CE)
REFERENCES CE_Codes(CE_Code)
);
Chaps 4&519
Licensing Tables
CSE
4701
CREATE TABLE Organization
(
Org_TIN Number(9) NOT NULL, Org_Name VarChar(60),
Org_DBA_Name VarChar(100), Org_Resident Char(2),
Org_Status Char(2), Org_Type Char(2),
Org_Complaints Number(5), Org_Appointments Number(5),
Org_Ind_Designations Number(5), Org_NIPR Number(10),
Org_Comments VarChar(2000),
CONSTRAINT PK_Organization PRIMARY KEY (Org_TIN),
CONSTRAINT FK_Org_Resident FOREIGN KEY (Org_Resident)
REFERENCES Resident(RE_Resident),
CONSTRAINT FK_Org_Status FOREIGN KEY (Org_Status)
REFERENCES I_O_Status(IS_Status),
CONSTRAINT FK_Org_Type FOREIGN KEY (Org_Type)
REFERENCES Organization_Types(OT_Type)
);
Chaps 4&520
Licensing Tables
CSE
4701
CREATE TABLE License
(
Lic_License_Number Number(9) NOT NULL,
Lic_TIN_Type Char(2) NOT NULL, Lic_TIN Number(9) NULL,
Lic_Class Char(2), Lic_Status Char(2),
Lic_License_Date Date, Lic_Cancel_Date Date,
Lic_Cancel_Reason Char(2), Lic_Suspend_Date Date,
Lic_Suspend_Reason Char(2), Lic_Original_Date Date,
Lic_Reinstatement_Date Date, Lic_Amendment_Date Date,
Lic_Print_Date Date,
CONSTRAINT PK_License PRIMARY KEY
(Lic_License_Number, Lic_TIN_Type),
CONSTRAINT FK_Lic_Status FOREIGN KEY (Lic_Status)
REFERENCES I_O_Status(IS_Status),
CONSTRAINT FK_Lic_Cancel_Reason FOREIGN KEY (Lic_Cancel_Reason)
REFERENCES I_O_Reason(IR_Reason),
CONSTRAINT FK_Lic_Suspend_Reason FOREIGN KEY (Lic_Suspend_Reason)
REFERENCES I_O_Reason(IR_Reason),
CONSTRAINT FK_Lic_Class FOREIGN KEY (Lic_Class)
REFERENCES I_O_Class(IC_Class)
);
Chaps 4&521
Licensing Tables
CSE
4701
CREATE TABLE License_LOA
( LLA_Lic_License_Number Number(9) NOT NULL,
LLA_Lic_TIN_Type Char(2) NOT NULL,
LLA_Lic_TIN Number(9) NOT NULL,
LLA_Life Char(1), LLA_Accident_Health Char(1),
LLA_Property Char(1),
LLA_Casualty Char(1), LLA_Variable_Annuities Char(1),
LLA_Variable_Life Char(1), LLA_Credit_Product Char(1),
LLA_Personal_Lines Char(1), LLA_Viaticals Char(1),
LLA_Surplus_Lines Char(1), LLA_BailBonds Char(1),
LLA_Rental_Cars Char(1), LLA_Travel_Accident_Baggage Char(1),
LLA_CA_All Char(1), LLA_CA_WC_Only Char(1),
LLA_CA_All_X_WC Char(1), LLA_CA_Auto_Only Char(1),
LLA_Auto_Physical_Damage Char(1), LLA_Premium_Finance Char(1),
LLA_Utilization_Review Char(1), LLA_Other Char(1),
LLA_Restriction VarChar(50),
CONSTRAINT PK_License_LOA PRIMARY KEY
(LLA_Lic_License_Number, LLA_Lic_TIN_Type),
CONSTRAINT FK_License_LOA FOREIGN KEY
(LLA_Lic_License_Number, LLA_Lic_TIN_Type)
REFERENCES License (Lic_License_Number, Lic_TIN_Type)
ON DELETE CASCADE
);
Chaps 4&522
Licensing Tables
CSE
4701
CREATE TABLE License_LOA
( LLA_Lic_License_Number Number(9) NOT NULL,
LLA_Lic_TIN_Type Char(2) NOT NULL,
LLA_Lic_TIN Number(9) NOT NULL,
LLA_Life Char(1), LLA_Accident_Health Char(1),
LLA_Property Char(1),
LLA_Casualty Char(1), LLA_Variable_Annuities Char(1),
LLA_Variable_Life Char(1), LLA_Credit_Product Char(1),
LLA_Personal_Lines Char(1), LLA_Viaticals Char(1),
LLA_Surplus_Lines Char(1), LLA_BailBonds Char(1),
LLA_Rental_Cars Char(1), LLA_Travel_Accident_Baggage Char(1),
LLA_CA_All Char(1), LLA_CA_WC_Only Char(1),
LLA_CA_All_X_WC Char(1), LLA_CA_Auto_Only Char(1),
LLA_Auto_Physical_Damage Char(1), LLA_Premium_Finance Char(1),
LLA_Utilization_Review Char(1), LLA_Other Char(1),
LLA_Restriction VarChar(50),
CONSTRAINT PK_License_LOA PRIMARY KEY
(LLA_Lic_License_Number, LLA_Lic_TIN_Type),
CONSTRAINT FK_License_LOA FOREIGN KEY
(LLA_Lic_License_Number, LLA_Lic_TIN_Type)
REFERENCES License (Lic_License_Number, Lic_TIN_Type)
ON DELETE CASCADE
);
Chaps 4&523
DDL: Creating an Index

CSE
4701
Create Index
 Creates an Index on the Named Attribute
 Improves Search Performance but With a Cost
 Index is Created in Ascending Order
 Unique Index Enforces Key Constraint
 Automatically Maintained by System and Changed
Dynamically
CREATE UNIQUE INDEX SNUM ON S-P(S#);
System Will Not Expect Two Tuples of Same Value for the
Attribute. Values of S# are Uniquely Identified.

Drop Index:
DROP INDEX SNUM;
Chaps 4&524
Indexes for Searching/Performance
CSE
4701
CREATE INDEX IX_Lic_Status on License(Lic_Status);
CREATE INDEX IX_Lic_License_Date on License(Lic_License_Date);
CREATE INDEX IX_Lic_Cancel_Date on License(Lic_Cancel_Date);
CREATE INDEX IX_Lic_Ind_Org_Com on License(Lic_TIN);
CREATE INDEX IX_Lic_TIN_Type on License(Lic_TIN_Type);
CREATE INDEX IX_Ind_Last_Name on Individual(Ind_Last_Name);
CREATE INDEX IX_Ind_DBA_Name on Individual(Ind_DBA_Name);
CREATE INDEX IX_Ind_Status on Individual(Ind_Status);
CREATE INDEX IX_Org_TIN on Organization(Org_TIN);
CREATE INDEX IX_Org_Name on Organization(Org_Name);
CREATE INDEX IX_Org_DBA_Name on Organization(Org_DBA_Name);
CREATE INDEX IX_Org_Status on Organization(Org_Status);
CREATE INDEX IX_Org_Type on Organization(Org_Type);
Chaps 4&525
SQL View for Licensing Inquiries

CSE
4701


Ind: Individual Table
Lic: License Table
Add: Addresses Table
CREATE OR REPLACE VIEW Individual_Demographic_View AS
SELECT Ind_Last_Name, Ind_First_Name, Ind_Middle_Name,
Ind_Title, Ind_Resident, Ind_Status, Ind_Ce,
Ind_Nipr,Lic_License_Number, Lic_Tin,Lic_Class,
Lic_Status, Lic_License_Date, Lic_Cancel_Date,
Lic_Suspend_Date, Lic_Reinstatement_Date,
Lic_Amendment_Date, Add_Address_Type,
Add_Lic_Tin, Add_Address1, Add_Address2,
Add_Address3, Add_Address4, Add_City,
Add_State, Add_Postal_Code, Add_Country,
Add_Phone1, Add_Phone2, Add_Fax,
Add_Email_Address, Add_Url
FROM
Individual, License, Addresses
WHERE ((Ind_SSN(+)=Lic_TIN) AND
(Lic_TIN(+)=Add_Lic_TIN));
Chaps 4&526
Deployment Over Time

CSE
4701





Renewal Tool to Process 70K Producer Renewals
 Renewal Slip with Bar Code
 Batches of Slip + Check
 Multiple Renewals (One Check, Multiple Slips)
 Reconcile and Track Payments
Extended to All License Classes
Tool for On-Line Processing of Mailed Applications
Inquiry Tool for Querying Licenses
Transitioned Entire License Division to Use New
System at Once
Transitioned Entire Insurance Dept. for License Inq.
Chaps 4&527
Consumer Affairs Database Design

CSE
4701
Again, Identify Key Entities of Information:
 Complaints
Focal Relation – John Doe initiates a complaint
Against the Lousy Insurance Company
Key

Complainants
Information

on John Doe
Against
Information
on the Lousy Insurance Company and
perhaps Agents, Agencies, etc.
Images, Historical Record, Lots of Coding
Result: Initial EER


Chaps 4&528
ER-Like Diagram for Consumer Affairs
CSE
4701
Chaps 4&529
ER-Like Diagram for Consumer Affairs
CSE
4701
Chaps 4&530
Consumer Affairs Tables
CSE
4701
CREATE TABLE Complaints
(
CMF_Number Number(9) NOT NULL, CMF_Type Char(2),
CMF_Date_Opened Date, CMF_Date_Closed Date,
CMF_Recovery Number(14,2), CMF_Exm1 Number (6),
CMF_Status Char(2), CMF_Reason Char(2),
CMF_Disposition Char(02), CMF_Enforcement Char(02),
CMF_Justification Char(2), CMF_Source Char(2),
CMF_Letter1 Char(2), CMF_Letter1_Date Date,
CMF_Letter2 Char(2), CMF_Letter2_Date Date,
CMF_SubType Char(2), CMF_Register Char(1),
CMF_Master Number(9), CMF_Comments VarChar(2000),
CONSTRAINT PK_Complaints PRIMARY KEY (CMF_Number),
CONSTRAINT FK_CMF_Master FOREIGN KEY (CMF_Master)
REFERENCES Complaints (CMF_Number),
CONSTRAINT FK_CMF_Exm1 FOREIGN KEY (CMF_Exm1)
REFERENCES Employees (Emp_Employee_Number),
CONSTRAINT FK_CMF_Status FOREIGN KEY (CMF_Status)
REFERENCES Complaint_Status(CU_Status),
CONSTRAINT FK_CMF_Reason FOREIGN KEY (CMF_Reason)
REFERENCES Complaint_Reason_Codes(RC_Code),
REM 5 MORE CONSTRAINST – OMITTED
);
Chaps 4&531
Consumer Affairs Tables
CSE
4701
CREATE TABLE Complainants
(
CMC_CMF_Number Number(9) NOT NULL, CMC_Sequence Number(3),
CMC_Last_Name VarChar(100), CMC_First_Name VarChar(25),
CMC_Middle_Name VarChar(25), CMC_Title VarChar(10),
CMC_Type Char(2), CMC_Address1 VarChar(30),
CMC_Address2 VarChar(30), CMC_City VarChar(30),
CMC_State Char(2), CMC_Postal_Code VarChar(10),
CMC_Country Char(2) Default 'US', CMC_Home_Phone Number(10),
CMC_Business_Address1 VarChar(30),
CMC_Business_Address2 VarChar(30),
CMC_Business_City VarChar(30), CMC_Business_State Char(2),
CMC_Business_Postal_Code VarChar(10),
CMC_Business_Country Char(2) Default 'US',
CMC_Business_Phone Number(10), CMC_FAX_Phone Number(10),
CMC_Status Char(2), CMC_Comments VarChar(2000),
CONSTRAINT PK_Complainants PRIMARY KEY
(CMC_CMF_Number, CMC_Sequence),
CONSTRAINT FK_Complainants FOREIGN KEY (CMC_CMF_Number)
REFERENCES Complaints(CMF_Number),
REM Four other constraints omitted.
);
Chaps 4&532
Consumer Affairs Tables
CSE
4701
CREATE TABLE Complaint_Against
(
CMA_CMF_Number Number(9) NOT NULL, CMA_Sequence Number(5),
CMA_Lic_License_or_Company Char (9), CMA_Lic_TIN_Type Char(2),
CMA_Type Char(2), CMA_Last_Name VarChar(50),
CMA_First_Name VarChar(25), CMA_Middle_Name VarChar(25),
CMA_Title VarChar(10), CMA_Address1 VarChar(30),
CMA_Address2 VarChar(30), CMA_City VarChar(30),
CMA_State Char(2), CMA_Postal_Code VarChar(10),
CMA_Country Char(2) Default 'US', CMA_Home_Phone Number(10),
CMA_FAX_Phone Number(10), CMA_Pager_Phone Number(10),
CMA_EMail VarChar(255), CMA_Business_Address1 VarChar(30),
CMA_Business_Address2 VarChar(30), CMA_Business_City VarChar(30),
CMA_Business_State Char(2), CMA_Business_Postal_Code VarChar(10),
CMA_Business_Country Char(2) Default 'US',
CMA_Business_Phone Number(10),
CMA_Business_FAX Number(10), CMA_Business_Pager Number(10),
CMA_Business_EMail VarChar(255), CMA_Status Char(2),
CMA_Comments VarChar(2000),
CONSTRAINT PK_Complaint_Against PRIMARY KEY
(CMA_CMF_Number, CMA_Sequence),
REM Six other constraints omitted.
);
Chaps 4&533
Consumer Affairs Tables
CSE
4701
CREATE TABLE Complaint_Against
(
CMA_CMF_Number Number(9) NOT NULL, CMA_Sequence Number(5),
CMA_Lic_License_or_Company Char (9), CMA_Lic_TIN_Type Char(2),
CMA_Type Char(2), CMA_Last_Name VarChar(50),
CMA_First_Name VarChar(25), CMA_Middle_Name VarChar(25),
CMA_Title VarChar(10), CMA_Address1 VarChar(30),
CMA_Address2 VarChar(30), CMA_City VarChar(30),
CMA_State Char(2), CMA_Postal_Code VarChar(10),
CMA_Country Char(2) Default 'US', CMA_Home_Phone Number(10),
CMA_FAX_Phone Number(10), CMA_Pager_Phone Number(10),
CMA_EMail VarChar(255), CMA_Business_Address1 VarChar(30),
CMA_Business_Address2 VarChar(30), CMA_Business_City VarChar(30),
CMA_Business_State Char(2), CMA_Business_Postal_Code VarChar(10),
CMA_Business_Country Char(2) Default 'US',
CMA_Business_Phone Number(10),
CMA_Business_FAX Number(10), CMA_Business_Pager Number(10),
CMA_Business_EMail VarChar(255), CMA_Status Char(2),
CMA_Comments VarChar(2000),
CONSTRAINT PK_Complaint_Against PRIMARY KEY
(CMA_CMF_Number, CMA_Sequence),
REM Six other constraints omitted.
);
Chaps 4&534
Data Manipulation Language - DML

CSE
4701


SQL has the SELECT Statement for Retrieving Info.
from a Database (Not Relational Algebra Select)
SQL vs. Formal Relational Model
 SQL Allows a Table (Relation) to have Two or
More Identical Tuples in All Their Attribute Values
 Hence, an SQL Table is a Multi-set (Sometimes
Called a Bag) of Tuples; it is Not a Set of Tuples
SQL Relations Can Be Constrained to Sets by
 PRIMARY KEY or UNIQUE Attributes
 Using the DISTINCT Option in a Query
Chaps 4&535
Download