Академический Документы
Профессиональный Документы
Культура Документы
Business Rules
CS263 Lecture 4
Introduction
Supertype/Subtype
relationships
Employee supertype
When to use
supertype/subtype relations
Patient example
Generalization and
specialization
Generalisation
Example of generalization
Three entity types: CAR, TRUCK, and MOTORCYCLE
Specialisation
Specialisation
Example of specialization
Entity type PART
Applies only to purchased parts
Only applies to
manufactured
parts
Created 2 subtypes
Completeness constraints
Completeness constraints
Partial Specialization Rule: No (single line) An entity
A vehicle could be a
car, a truck, or neither
Disjointness constraint
Disjointness constraint
Overlap Rule: An instance of the supertype can simultaneously
Overlap rule
Subtype discriminators
Subtype discriminators
Subtype discriminators
Overlapping a composite attribute whose subparts
A composite attribute
with sub-attributes
indicating yes or no
to determine whether it
is of each subtype
Defining supertype/subtype
hierarchies
Defining supertype/subtype
hierarchies
Defining supertype/subtype
hierarchies
Defining supertype/subtype
hierarchies
Entity clustering
Entity clustering
Entity clustering
Related
groups of
entities could
become
clusters
More readable,
isnt it?
Business rules
EER depiction of
business rules
classification
Business rules
Derived facts
Derived facts
Business rule 1
Corresponding object
Action assertion
is a Restriction
Anchor object
Corresponding object
Business rule 2
Business rule 2
Business rule 2
Corresponding object
Upper LIMit
Anchor object
Action assertion
Schema definition
Schema definition
Creating indexes
Creating indexes
Creating indexes
SELECT
The first two are required, and the third is necessary when
only certain table rows are to be retrieved, or multiple
tables are to be joined
Following Fig. Shows how we can display product name
and quantity from the PRODUCT view for all products
costing less than $275
SELECT Example
Distinct and *
If the user does not want to see duplicate rows in the result,
SELECT DISTINCT can be used, so SELECT DISTINCT
PRODUCT_NAME would display a results table without
duplicate rows
SELECT * (where * is a wildcard to indicate all columns)
displays all columns from all the tables or views in the
FROM clause
Using expressions
Using functions
Using functions
Using wildcards
Using wildcards
Sorting results
ORDER BY - sorts the final result rows in ascending or
descending order
GROUP BY - groups rows in an intermediate results
table where the values in those rows are the same for
one or more columns
HAVING - can only be used following GROUP BY and
acts as a secondary WHERE clause, returning only
those groups which meet a specified condition
ORDER BY
e.g. list customer, city and state for all customers in the
CUSTOMER view whose address is in Florida, Texas, California or
Hawaii. List the customers alphabetically by state, and
alphabetically by customer within each state: i.e. sort the results
first by STATE, and within a state by CUSTOMER_NAME:
GROUP BY
GROUP BY
GROUP BY
HAVING
e.g. list the product finish and average standard price for
each finish for selected finishes where the average standard
price is less than $750:
SELECT PRODUCT_FINISH,
AVG(STANDARD_PRICE)
FROM PRODUCT_V WHERE PRODUCT_FINISH
IN(Cherry, Natural Ash, Natural Maple, White Ash)
GROUP BY PRODUCT_FINISH
HAVING AVG(STANDARD_PRICE) < 750
ORDER BY PRODUCT_FINISH;
SQL statement
processing order