Sunteți pe pagina 1din 25

Balochistan University of Information Technology, Engineering & Management Sciences

Introduction to
Database Systems
Mohammad Imran
Lecturer
Department of Information Technology
Balochistan University of Information Technology, Engineering & Management Science

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 1
Balochistan University of Information Technology, Engineering & Management Sciences

Lecture 2
Database Design &
Data Modeling

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 2
Balochistan University of Information Technology, Engineering & Management Sciences

Why Database Design Is Important


• Database design focuses on design of database structure
used for end-user data
o Designer must identify database’s expected use
• Well-designed database:
o Facilitates data management
o Generates accurate and valuable information
• Poorly designed database:
o Causes difficult-to-trace errors
Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015
Balochistan University of Information Technology, Engineering & Management Sciences

Database Modeling
• Database design focuses on how the database structure
will be used to store and manage end-user data
• Database Modeling is first step in designing a database
• Process of creating a specific data model for a determined
problem domain

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 4
Balochistan University of Information Technology, Engineering & Management Sciences

Data Modeling and Data Models


• Data models
o Relatively simple representations of complex real-world
data structures
• Often graphical
• Model: an abstraction of a real-world object or event
o Useful in understanding complexities of the real-world
environment
• Data modeling is iterative and progressive

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015
Balochistan University of Information Technology, Engineering & Management Sciences

Why Data Modeling?


• Designers, programmers, and end users see data in
different ways
• Different views of the same data can lead to database
designs that do not reflect an organization’s actual
operation
• Failure to meet end-user needs and data efficiency
requirements
• Data model organizes data for various users
Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015
Balochistan University of Information Technology, Engineering & Management Sciences

Data Model Basic Building Blocks


• Entity: anything about which data are to be collected and
stored
• Attribute: a characteristic of an entity
• Relationship: describes an association among entities
o One-to-many (1:M) relationship
o Many-to-many (M:M) relationship
o One-to-one (1:1) relationship
• Constraint: a restriction placed on the data
Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015
Balochistan University of Information Technology, Engineering & Management Sciences

Business Rules
• Descriptions of policies, procedures, or principles within a
specific organization
o Apply to any organization that stores and uses data to
generate information
o Must be in written form and kept up to date
o Must be easy to understand and widely disseminated
• Describes characteristics of data as viewed by the
company

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015
Balochistan University of Information Technology, Engineering & Management Sciences

Sources of Business Rules


• Company managers
• Policy makers
• Department managers
• Written documentation
o Procedures, Standards, Operations manuals
• Direct interviews with end users

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015
Balochistan University of Information Technology, Engineering & Management Sciences

Translating Business Rules into


Data Model Components
• Nouns translate into entities
• Verbs translate into relationships among entities
• Relationships are bidirectional
• Two questions to identify the relationship type:
o How many instances of B are related to one instance of
A?
o How many instances of A are related to one instance of
B?

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015
Balochistan University of Information Technology, Engineering & Management Sciences

Naming Conventions
• Naming occurs during translation of business rules to data
model components
• Names should make the object unique and distinguishable
from other objects
• Names should also be descriptive of objects in the
environment and be familiar to users
• Proper naming:
o Facilitates communication between parties
o Promotes self-documentation
Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015
Balochistan University of Information Technology, Engineering & Management Sciences

Levels of Data Modeling


• The three levels of data modeling
o Conceptual data model
o Logical data model
o Physical data model

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 12
Balochistan University of Information Technology, Engineering & Management Sciences

Conceptual Model
• A conceptual data model identifies the highest-level
relationships between the different entities
• Features of conceptual data model include:
o Important entities and the relationships among them
o No attribute is specified
o No primary key is specified
• It is input for Logical Data Model

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 13
Balochistan University of Information Technology, Engineering & Management Sciences

Conceptual Model
• Represents a global view of the entire database by the
entire organization
• Also known as a conceptual schema
• The most widely used conceptual model is the ER
model
• Remember that the ER model is illustrated
with the help of the ERD, which is effectively
the basic database blueprint

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 14
Balochistan University of Information Technology, Engineering & Management Sciences

Conceptual Model

Fig. Conceptual Model


Source: http://www.1keydata.com/datawarehousing/conceptual-data-model.html

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 15
Balochistan University of Information Technology, Engineering & Management Sciences

Logical Model
• Describes the data in as much detail as possible, without
concerning how they will be physical implemented in the
database
• Features of a logical data model include:
o Includes all entities and relationships among them
o All attributes for each entity are specified
o The primary key for each entity is specified
o Foreign keys (keys identifying the relationship between
different entities) are specified
o Normalization occurs at this level
Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 16
Balochistan University of Information Technology, Engineering & Management Sciences

Logical Modeling Steps


• The steps for designing the logical data model are as
follows:
o Specify primary keys for all entities
o Find the relationships between different entities
o Find all attributes for each entity
o Normalization
• Logical Data Model is input for Physical Model

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 17
Balochistan University of Information Technology, Engineering & Management Sciences

Logical Model- An Example

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 18
Balochistan University of Information Technology, Engineering & Management Sciences

Difference between Logical and Conceptual Model


Concept Model Logical Model
• No primary key is present • Primary keys are present
• No attributes are specified • Attributes are specified
within an entity within an entity
• Relationships are simply • Relationships between
stated, not specified
entities are specified using
o we simply know that two
entities are related, but we do primary keys and foreign
not specify what attributes keys
are used for this relationship

19
Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 19
Balochistan University of Information Technology, Engineering & Management Sciences

Physical Data Model


• Represents how the model will be built in the database
• Shows all table structures, including field name, field data type, field
constraints, primary key, foreign key, and relationships between
tables
• Features of a physical data model include:
o Specification all tables and columns
o Foreign keys are used to identify relationships between tables
o Different for different RDBMS
• For example, data type for a column may be different between MySQL and
SQL Server

Fundamentals of Information Technology Spring 2015 Mohammad Imran


Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 20
Balochistan University of Information Technology, Engineering & Management Sciences

Physical Data Modeling Steps


• The steps for physical data model design:
o Convert entities into tables
o Convert relationships into foreign keys
o Convert attributes into columns
o Modify the physical data model based on physical
constraints / requirements

Fundamentals of Information Technology Spring 2015 Mohammad Imran


Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 21
Balochistan University of Information Technology, Engineering & Management Sciences

Physical Data Model - Example

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 22
Balochistan University of Information Technology, Engineering & Management Sciences

Difference between Logical and Physical Model


Logical Model Physical Model
• Entity Names • Entity names are now table
names
• Attributes • Attributes are now field
names
• Data types not specified • Data type for each column
is specified

23
Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 23
Balochistan University of Information Technology, Engineering & Management Sciences

Conceptual, Logical and Physical Model


Bird’s Eye View
Feature Conceptual Logical Physical
Entity Names ✓ ✓
Entity Relationships ✓ ✓
Attributes ✓
Primary Keys ✓ ✓
Foreign Keys ✓ ✓
Table Names ✓
Column Names ✓
Column Data Types ✓

Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015 24
Balochistan University of Information Technology, Engineering & Management Sciences

Thank you

25
Introduction to Database Systems Spring 2015 Mohammad Imran April 13, 2015

S-ar putea să vă placă și