database analysis chandra s. amaravadi 1. in requirements analysis.. overview of database analysis...
TRANSCRIPT
DATABASE
ANALYSIS
Chandra S. Amaravadi
1
IN REQUIREMENTS ANALYSIS..
Overview of database analysis (requirements)
User views
Integrity constraints
Steps in database analysis
The ER model
Guidelines and examples
ER Additional semantics
2
OVERVIEW OF
DATABASE ANALYSIS
3
THE DEVELOPMENT CYCLE
Planning
Analysis (Requirements definition)
Design (Logical & Physical)
Implementation
Maintenance
4
The database development cycle consists of:
DATABASE ANALYSISDatabase Analysis is the stage of the development cycle that is concerned with identifying and modelling the data requirements of the organization.
Primary database analysis takes place duringthis stage
5
INFORMATION COLLECTED DURING RD
Information regarding data structure (from Views)
Information regarding rules/constraints e.g. weight limit
6
Two types of information are gathered:
IDENTIFYING DATA STRUCTURE
Receipts
Forms
Reports and memos
Screen displays
Schedules etc.
A view is a user’s representation of data (also the wayit is presented to them):
7
Information identified:
Eclasses
Attributes
Rules if any
AN EXAMPLE OF A VIEW
QUOTATION
Qty Description Price
Quote no: A61-45
Date: June 15,’12
8
IDENTIFYING CONSTRAINTS
INTEGRITY CONSTRAINTS
Domain
Business constraints
Database constraints
Entity integrity
referential integrity
Are rules to preserve integrity of the database
9
EXAMPLES OF CONSTRAINTS
DOMAIN CONSTRAINTSConstraints on allowable value of an attr.
e.g. E_name is alphabetic, E_address is alphanumeric
ENTITY & REFERENTIAL INTEGRITY
Primary key; Pkey <> Null
Referential integrity; values of cross-reference keys in different tables must match.
BUSINESS CONSTRAINTSRules concerning data: customers, purchases etc.
e.g. credit limit > $4,000, enrollment limit for course
DATABASE CONSTRAINTS:
10
STEPS IN DATABASE ANALYSIS (FYI)
The different steps in database analysis are:
1. Define scope (from planning stage)
2. Select methodology (ER, UML)
3. Identify views of data
4. Develop conceptual data model
5. Cross-check with planning
6. Specify constraints
11
TOP DOWN VS BOTTOM-UP
Enterprise Analysis
Enterprise Model
Proposed Database
Target Database
Data Model*
User views
Cross-check
*Note: the terms data model, conceptual data model and ER Model are synonymous12
The enterprise model is cross-checked with the data model
THE ER METHODOLOGY
13
ER MODEL
Introduced in 1976 Became popular Used to communicate requirements
14
A method for drawing data models
Entity classes
Attributes
Multi-valued
Derived
Relationships
Degree/cardinality concepts
Class/subclass
Recursive
BASIC MODELLING CONCEPTS
15
ENTITY CLASSES
Entity Class – Collection of related entities.
CUSTOMER
Common nouns (concepts are fine too!)
Customers, Products, Students etc.
Cannot be attributes or proper nouns
Cannot be database concepts
CUST#
16
ATTRIBUTES
Attribute – Property of an Entity Class
CUSTOMER
Generally on top of eclass
or below eclass or side
Use ovals
Underline pkey
Name PhoneID
17
ATTRIBUTES..
CUSTOMER
Name PhoneID
WorkHome
18
CUSTOMER
Name
ID
phone
MULTI-VALUED ATTRIBUTES..
An attribute which can have more than one set of valuesper entity instance.
19
DERIVED ATTRIBUTES
An attribute whose value can be derived or computedfrom other attributes e.g.
Do not include derived attributes in your ER model
20
total # of students
GPA
average score
RELATIONSHIPS
Relationships: logical and meaningful connectionsbetween two or more entity classes.
CUSTOMER
Name PhoneCust#
Places ORDER
Use diamonds, label
L-R, T-B ordercardinality,degree
21
CARDINALITY
CARDINALITY -- Number of entities that participate in a
relationship. Can be 1:1, 1:M or M:N
Between two entity classes A and B, these are defined as follows:
1:1 -- Each instance of A is associated with one instance of B
and vice versa.
1:M -- Each instance of A is associated with many instances of B.
Each instance of B is associated with one instance of A.
M:N -- Each instance of A is associated with many instances of B
and vice versa.
22
Max cardinality rule: In > 2 way relationships,Use max cardinality
DISCUSSION
IDENTIFY THE CARDINALITIES OF THE
FOLLOWING RELATIONSHIPS
company -- president
instructor -- students
flights -- pilots
city -- convention centers
department -- employees
sports team (“pro”) -- players
company -- city
books – authors
city -- subdivisions
23
DEGREE OF A RELATIONSHIP
The Degree of a relationship: The number of entityclasses that participate in the relationship:
24
CUSTOMER Places ORDER
PRODUCTS
If it is one UnaryIf two BinaryIf three TernaryIf four Quarternary
DEGREE..physician chair of assoc.
25
Max cardinality rule:In > 2 way relationships,Use max cardinality
CUST.
OLD CUST.
CLASS/SUBCLASS RELATIONSHIPS..
Is-a
Class/Superclass
Sub-classes
Class/subclass: Entity classes can be grouped into parent/child or superclass/class or Class/subclassrelationships based on common characteristics. NEW CUST.
26
CUST.
OLD CUST.
CLASS/SUBCLASS RELATIONSHIPS..
Is-a
Class/Superclass
Sub-classes
The attr. of a sub-class are inherited fromthe parent class,but can have additionalattributes
NEW CUST.
Join dt
Member#
27
ABBREVIATED CLASS/SUBCLASS
CAR
GM
Is-a
Class/Superclass
FORD
(Exclusive, Non exhaustive)
28
SUMMARY OF CONCEPTS
Entity – Individual example of person, place or thing.Entity Class – Collection of related entities.Attributes – Properties of entity classes about which we would like to collect information.Multi-valued – An attribute with more than one set of valuesattribute per entity instance.Relationship -- Logical and meaningful connection between two or more entity classes.Class/subclass- Grouping of entities based on common char.Cardinality -- Number of entities participating in a relationship.Degree -- Number of eclasses participating in a relationship.Unary / -- A relationship among entities within an recursive eclass
29
Entity classes
Relationships
Attributes
Multivalued attributes
Class/ subclass
1 : 1
1 : M
M : N
NOTATION
THE ER
30
DRAWING THE ER CHART
Identify the eclasses (and attributes)
Identify relationships among eclasses
decide which relationships to show
verbalize and map relationships
Use rectangles for eclasses , diamonds
for the relationships
Depict cardinalities
Draw attributes (underline Pkey)
Handle the special cases
31
AN EXAMPLE ER CHART
CUSTOMER
ORDERS
Places
Cust#Cust# NameName
PRODUCTSAre for
32
ER CORRECT EXAMPLES
33
ER INCORRECT EXAMPLES
House
1403 W Adams
34
1. A product can be on one or more orders
2. A student can have one or more loans at a bank. The bank maintains the following information ss#, name, address, loan id, amt, duration, balance, branch#, branch_mgr.
3. A judge tries cases in a court. A case can be a civil case or a criminal case.
4. The DMV issues several types of licenses to drivers: passenger car, chauffeur, motorcycle, farm vehicle.
5. A basketball team plays games against other teams.
EXAMPLE PROBLEMSMODEL THE FOLLOWING USING ER
35
ADDITIONAL COMMENTSBuild model around central e-class
Use only vertical and horizontal lines
Decide whether attributes belong with
eclasses, or relationships
Assume additional attributes if needed
Do not show computed attributes or values
Avoid cycles
Refine, refine...
36
ER CHECK LIST
All entity classes depicted?
sub classes shown?
cardinalities shown?
All attributes included/labelled?
multi-valued attr. Shown (if any)?
computed attr. omitted?
pkeys marked? Fkeys omitted?
Relationships correct/labelled?
relationship attributes? recursive?
cycles avoided?
37
Once an ER diagram is drawn, go through this check list:
ER ADVANCED SEMANTICS
38
EXCLUSIVE AND NON-EXCLUSIVE
BooksIs
a
Fictionnon-
Fiction
EXCLUSIVE
Books
Is a
Science Poetry
NON-EXCLUSIVE
39
Arts History
40
EXHAUSTIVE AND NON-EXHAUSTIVE
BooksIs
a
Fictionnon-
Fiction
EXHAUSTIVE
Books
Is a
Literature Poetry
NON-EXHAUSTIVE
Books
Computers Business
ER ADVANCED SEMANTICS..
NON-EXCLUSIVE AND
NON-EXHAUSTIVE
Is a
41
RELATIONSHIP ATTRIBUTES
CLIENT
sells
HOUSE
AGENT
Insert sale date?commission?
42
UNARY/RECURSIVE RELATIONSHIPS
EmployeeEmployee
Unary 1:1
EmployeeEmployee
Unary 1:M
relationships among entities within an eclass
ElderJacobsSmithWhite
ElderJacobsSmithWhite
43
EXCLUSIVE: When an entity of an entity class belongs to one or other of the
subtypes given (i.e. the eclass cannot be classified into more than one subtype)
NON EXCLUSIVE: When an entity of an entity class belongs to more than one
subtype given (i.e. the classification is non-exclusive)
EXHAUSTIVE: When all possible subtypes have been enumerated [listed].
(i.e. there are no more subtypes)
NON EXHAUSTIVE: When there are some subtypes which have not been
enumerated (all subtypes are not listed).
ER ADVANCED SEMANTICS..
Note: A subtype is equivalent to a subclass
44
ER ADVANCED SEMANTICS
Mandatory 1
cardinality
Optional 0, 1
cardinality
1,2..M cardinality
Optional 0,1..M
cardinality
Note: You can ignore min/ Max Cardinalities unless you are specifically asked to represent them.
45
ER ADVANCED SEMANTICS..
Person: Child
Proj mgr: Proj (assume every proj has one proj manager and every project manager has at least one proj)
Person: Spouse
Faculty: Office (assume every faculty has one office and each office is occupied by at least one faculty)
Student: Major(assume every student has one major and each major has at least one student)
46
What are the sources of info. for database analysis?
What are the outputs of database analysis?
How can we distinguish between an attr. and an entity class?
When is an ER model complete?
Are foreign keys shown on ER?
What are examples of performance constraints?
What is the difference between domain and business constraints?
DISCUSSION
47
Would the name of the organization be included in
an ER diagram?
Draw ER for: Customer places order with salesperson
Suppose a company has eclasses, R,S & T. If R and S,
T & S and R & T are related, draw an ER diagram.
Suppose you have an organization having entity
classes P, Q and R and S. Assuming P & Q; R & Q;
P&R; R&S are related, draw an ER diagram.
DISCUSSION..
48
49