basic database analysis(database)
DESCRIPTION
TRANSCRIPT
Lecture 3: Basic Database Analysis
ISOM3260, Spring 2014
2
Where we are now• Database environment
– introduction to database• Database development process
– steps to develop a database• Conceptual data modeling
– entity-relationship (ER) diagram; enhanced ER• Logical database design
– transforming ER diagram into relations; normalization• Physical database design
– technical specifications of the database• Database implementation
– Structured Query Language (SQL), Advanced SQL• Advanced topics
– data and database administration
3
Database development activities during SDLC
Top-downanalysis
4
Basic Database Analysis
• Business Rules• E-R Model• Entities• Attributes• Relationships
5
Business Rules
• Statements that define or constrain some aspect of the business
• Include– names and definitions of entity types, attributes, and
relationships– constraints on above data objects
• Expressed in terms familiar to end users– e.g. Every student in the university must have a faculty
advisor• Automated through DBMS software• Some business rules cannot be represented in E-R
diagram; instead they are stated in natural language
6
Figure 2-1: Sample E-R Diagram
7
Figure 2-2: Basic E-R Notation
Entity symbols
Relationship symbols
Attribute symbols
A special entity that is also a relationship
8
E-R Model Constructs• Entity - person, place, object, event,
concept• Entity Type versus Entity Instance
9
What Should an Entity Be?
• SHOULD BE:– an object that will have many instances in the
database– an object that will be composed of multiple attributes– an object that we are trying to model
• SHOULD NOT BE:– a user of the database system – an output of the database system (e.g. a report)
10
Inappropriate entities
System user System output
Appropriate entities
Figure 2-4
11
Strong vs. Weak Entity Type
• Strong entity – exists independently of other types of entities– has its own unique identifier– represented with single-line rectangle
• Weak entity– dependent on a strong entity…cannot exist on its own– does not have a unique identifier– represented with double-line rectangle
• Identifying relationship– links strong entities to weak entities– represented with double line diamond
12
Figure 2-5: Strong and weak entities
13
Attributes
• Attribute– property or characteristic of an entity type
• Classifications of attributes– Simple versus Composite Attribute– Single-Valued versus Multivalued Attribute– Stored versus Derived Attributes– Identifier Attributes
14
Figure 2-7: A composite attribute
An attribute broken into component parts
15
Figure 2-8: Entity with a multivalued attribute (Skill) and derived attribute (Years_Employed)
Derived from date employed and current date
Multivalued: an employee can have more than one skill
16
Identifier Attribute
• Identifier (or key)– an attribute (or combination of attributes) that
uniquely identifies individual instances of an entity type
• Simple Key versus Composite Key• Candidate Key
– an attribute that could be a key…satisfies the requirements for being a key
17
Characteristics of Identifiers
• Will not change in value• Will not be null• No intelligent identifiers
– e.g. containing locations that might change• Substitute new, simple keys for long, composite keys
– e.g. Game_Number instead of Home_Team and Visiting_Team
18
Figure 2-9a: Simple key attribute
The key is underlined
19
Figure 2-9b: Composite key attribute
The key is composed of two subparts
20
Relationships
• Relationship Types vs. Relationship Instances– the relationship type is modeled as the diamond
and lines between entity types…the instance is between specific entity instances
• Relationships can have attributes– these describe features pertaining to the
association between the entities in the relationship
21
Figure 2-10a: Relationship type (Completes)
Figure 2-10b: Relationship instances
22
Figure 2-11a: A binary relationship with an attribute
Here, the Date_Completed attribute refers to the employee’s completion of a course…it is an attribute of the relationship
23
Associative Entities• It’s an entity – it has attributes• AND it’s a relationship – it links entities together
• When should a relationship with attributes instead be an
associative entity? – all relationships for the associative entity should be many– the associative entity could have meaning independent of the other
entities– the associative entity preferably has a unique identifier, and should
also have other attributes– the associative entity may be participating in other relationships other
than the entities of the associated relationship– ternary relationships should be converted to associative entities
24
Figure 2-11b: An associative entity (CERTIFICATE)
Associative entity involves a rectangle with a diamond inside.Note that the many-to-many cardinality symbols face toward the associative entity and not toward the other entities.
25
Degree of a Relationship
• Degree of a Relationship is the number of entity types that participate in it– Unary Relationship (degree 1)– Binary Relationship (degree 2)– Ternary Relationship (degree 3)
26
Figure 2-2: Degree of relationships
One entity related to another of the same entity type
Entities of two different types related to each other
Entities of three different types related to each other
27
Figure 2-12a: Unary relationships
28
Representing a bill-of -materials structure
Figure 2-13a: A unary relationship with an attribute. This has a many-to-many relationship
29
(b) Two instances
30
Figure 2-13c: An associative entity – bill of materials structure
31
Figure 2-12b: Binary relationships
32
Figure 2-12c: Ternary relationships
33
Figure 2-14: Ternary relationships as an associative entity
34
Cardinality of Relationships
• One–to–One– each entity instance in the relationship will have
exactly one related entity instance• One–to–Many
– an entity instance on one side of the relationship can have many related entity instances, but an entity instance on the other side will have a maximum of one related entity instance
• Many–to–Many– entity instances on both sides of the relationship can
have many related entity instances on the other side
35
Cardinality Constraints
• Cardinality Constraints– the number of instances of one entity that can or must
be associated with each instance of another entity
• Minimum Cardinality– if zero, then optional– if one or more, then mandatory
• Maximum Cardinality– the maximum number
36
Figure 2-2: Cardinality
37
Figure 2-16a: Basic relationship with only maximum cardinalities showing
Figure 2-17a: Mandatory cardinalities
38
Figure 2-17b: One optional, one mandatory cardinality
39
Figure 2-17c: Optional cardinalities
40
Figure 2-18: Cardinality constraints in a ternary relationship
41
More about Relationships
• Modeling Time-Dependent Data– Time Stamps (such as date and time)
• Multiple Relationships– more than one relationship between the same
entity types
42
Figure 2-19: Example of time stamping
43
Examples of multiple relationships – entities can be related to one another in more than one way
Figure 2-21a: Employees and departments
44
Figure 2-21b: Professors and courses (fixed upon constraint)
Maximum cardinality constraint is 4
45
Figure 2-22: E-R diagram for Pine Valley Furniture