Vous êtes sur la page 1sur 41

Database Modeling

Suliman Mohamed
Lecture Content
oFirst Section : introduction Database Modeling
oSecond Section : Database Modeling Tools
(Sqldeveloper DataModelre)
oThird Section : Assignments
Data Model Definition
precise description of the data content in a system ,
using easy to understand graphic symbol
Data Model describe
data
data relationships
data semantics
data constraints
Data Model Types

1. Conceptual: describes WHAT the system


contains
2. Logical: describes HOW the system will be
implemented, regardless of the DBMS
3. Physical: describes HOW the system will be
implemented using a specific DBMS
Data Modeling goals
To aid in the development of database design that does not allow
anomalies or inconsistencies

Using model devein systems to create physical database with tables


that do not contain duplicate data values that can become
inconsistent
Known Data Models
Entity-Relationship (E-R) Models (suitable for relational model)
Only addresses data and relationships
Classic, simplest
Many extensions/variations exist
Basis for most other modeling approaches
UML (unified modeling language) (suitable for object oriented
models)
Class models
Goes beyond data, also models behaviors
Creating data model steps
1. Identify entities

2. Identify entity attributes and primary keys

3. Specify relationships
Data Entities
Entity
A "thing" about which you want to store data in an
application
Multiple examples (instances) of the entity must exist
Goal:
Store data about each entity in a separate table
Do not store duplicate data in multiple tables or records
Examples: CUSTOMER, PRODUCT
Data Model Naming Conventions
Entity names are short, descriptive, compound
word singular nouns
UWEC_STUDENT, CANDY_PRODUCT,
Entity names will ultimately correspond to
table names
Why singular?
Makes more sense when you start talking
about relationships
Data Entity Instances
Entity instance
A specific occurrence (data value) of an entity
An entity must have multiple entity instances
or it is not really an entity!
Examples: Davey Jones, Celestial Cashew
Crunch
ER Model Attributes
Attribute
A characteristic (data field) of an entity that you want to
store in the database
Examples: CUST_ID, PROD_DESC

Attribute value
The value of a particular attribute for a particular entity
instance
Examples: 42, "Nuts Not Nachos"
ER Model Notation
Represent entities as rectangles
List attributes within the rectangle

Entity
Primary key
Specific DBMS Naming Conventions
Oracle, MySQL: words separated by underscores
EMPLOYEE, EMPLOYEE_NAME, candy_product
Why? Oracle forces all object names to upper-case letters, MySQL forces all
names to lower-case on Windows

SQL Server: Use mixed case


Employee, EmployeeName
Preserves mixed-case notation

To be safe, always separate words with underscores!


Attributes Selection Issues
Primary key
Atomic
Composite
Multi-valued
Derived
Primary Key Attributes
Must be values that are:
Unique for every possible record
Do not change
Best practice: numeric with no blank spaces or formatting characters

Often you need to create a surrogate key


ID value that serves only to identify the object in the database
Exception: objects with "natural" primary keys
SKU
ISBN
VIN
Atomic and Composite Attributes
Atomic attribute: represents a single data value
15, Daniel", 12/25/2009

Composite attribute: can be decomposed into atomic attributes


"James B. Brown"
"5580 Pinewood Road, Eau Claire, WI 54701"
Should you ever allow a composite attribute in a database?
Composite Attributes

Decompose into atomic components for:


Sorting
Searching
Formatting
Student_First_Name
Student_MI
Student_Last_Name

Student
Student_ID Student_Address_Line_1
Student_Name Student_Address_Line_2
Student_Address Student_City
Student_DOB Student_State
Student_Class Student_Country
Student_Postal_Code
Multi-Valued Attributes
Can have multiple values for the same entity

Student Employee
Student_ID (PK) Employee_ID (PK)
Student_First_Name Employee_First_Name
Student_Last_Name Employee_Last_Name
Student_Address Employee_Address
Student_DOB Employee_DOB
Student_Class Employee_Dependent1
Student_Phone1 Employee_Dependent2
Student_Phone2
Handling Multi-valued Attributes
If it has a definite maximum number, leave as a repeating
attribute
If the upper limit is variable, make a new entity

Student Employee Dependent


Student_ID Employee_ID Dependent_ID
Student_First_Name Employee_First_Name has Dependent_Name
Student_Last_Name Employee_Last_Name
Student_Address Employee_Address
Student_DOB Employee_DOB
Student_Class Employee_Dependent1
Student_Phone1 Employee_Dependent2
Student_Phone2
Derived Attributes
Value that can be derived from other attributes
Student_Age = 22 (DOB = 11/20/1986, current date
is 11/13/2009)
Order_Total = $500 (Item 1 cost = $200, Item 2 cost
= $300)
Handling Derived Attributes
Store the underlying data values from which you can derive the
attribute value
Examples:
DOB => Age
CurrentPrice and UnitsSold of an item (for a sales order)

unless the underlying values can change!


PRODUCT_PRICE, COURSE_CREDITS
Data Model Relationships
Specify the number of instances of one entity that can be associated
with instances of a related entity
Types:
1:M
1:1
M:M

M denotes some value greater than 1 whose upper bound is undetermined


This is called relationship cardinality
Example 1:M Relationship

Store Store_ID Store_Name Store_Address


Store_ID 1 Northside 3233 Wisconsin St.
Store_Name 2 Southside 4211 Golf Road
Store_Address

Rents
Video_ID Video_Title Video_Format
Video 1000 The Princess Bride DVD
Video_ID
Video_Title 1001 Sideways Bluray
Video_Format
1002 Just Visiting DVD
1003 Crash Bluray
Example 1:1 Relationship

Spouse Spouse_ID Spouse_Name


Spouse_ID
52 Ryan, Judy
Spouse_Name
53 Redmann, Rudy
Has

Customer Customer_ Customer_ Customer_Address


Customer_ID ID Name
Customer_Name
1 Ryan, Paul 5454 Hyde Court
Customer_Address
2 Myers, Mary 112 Birch Place
Example M:M Relationship

Video
Video_ID
Video_Title

Rents

Customer
Customer_ID
Customer_Name
Customer_Address
Example ER Model
Section Two
Oracle SQL Developer Data Modeler

Multi-level Data Modeling across platforms within one


integrated system
Designing logical Entity Relation Diagrams (ERD)
Multi-dimensional modeling
User Defined Data Types
Building relational schema designs
Generating and executing DDL scripts
Reverse engineering of existing data structures
Import of data models from CA ERwin and Oracle
Designer
Multi-level relational and physical design environment
Multiple platform support
Multiple database support
Increases migration productivity
Read only visualization of database data models
Logical Modeling

Model entities, attributes and


relations
Support for
Super type
Sub types
Transform one logical to many
relational and multidimensional
models
Support for configurable
forward and reverse
engineering
Support for different modeling
notations
Relational Modeling

Model tables, columns and


FKs
Create one logical for one or
more relational models
Support configurable forward
and reverse engineering
Use subviews to work with a
subset of tables
Provide different displays of
the same model
Forward and Reverse Engineering (Transformation)
Each logical model to maps to
one or more relational models
Each relational model maps to
one logical model
Each relational model maps to
one or more physical models
Each physical model maps to
one relational model
Engineering options
General
Compare/copy
Synchronization
Include design glossary and
naming standards
Physical Modeling

One relational model for many physical


models
Add support for
Tablespaces
Users
Roles
Stored procedures
Probate properties
Apply properties to many elements at once
Supports
Oracle9i, Oracle Database 10g and
Oracle Database 11g
Microsoft SQL Server 2000 and 2005
IBM DB2/390 and DB2 LUW
Modeling DataTypes

Support for SQL99 (Object


Relational Modeling)
Distinct Types
(Predefined) Structured Types
(Predefined) Collection Types
Used in logical models
Used in relational models
Included on import
Generated in DDL
Multi-Dimensional Modeling

Modeling of Cubes,
Dimensions, Levels and
Hierarchies, Measures and
slices
Start from ROLAP, XMLA or
from scratch
Generate Oracle Analytical
Workspaces
Exporting and Code Generation
DDL file editor supports
Design Rules
Object selection
Drop objects
Table scripts
Standard database DDL
scripts
Oracle
IBM DB2 and UDB
Microsoft SQL Server
Multi-Dimensional Oracle AW,
Cube Views and XMLA
CSV export
Wednesday, September
Section Three
Assignments
Mission
Distribute in ten Groups
Each group have 7 students maximum
Each group will design, build and document a
database of its choice
Each group can chose the database wants to work on
from the provided lists
Database
E- eduation system database
National register Database
Voting system database for Sudan.
Health Management information system for Sudan Database.
E- newspaper Database

Vous aimerez peut-être aussi