0% found this document useful (0 votes)
17 views17 pages

Lec 09

The document outlines the process of database design, detailing the steps involved in logical and physical database modeling, including normalization and the relational database model. It emphasizes the importance of developing a logical data model, translating it into a physical design, and ensuring data integrity through various constraints. Additionally, it discusses the transformation of E-R diagrams into relations and the significance of primary and foreign keys in maintaining relational integrity.

Uploaded by

oracledb53
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views17 pages

Lec 09

The document outlines the process of database design, detailing the steps involved in logical and physical database modeling, including normalization and the relational database model. It emphasizes the importance of developing a logical data model, translating it into a physical design, and ensuring data integrity through various constraints. Additionally, it discusses the transformation of E-R diagrams into relations and the significance of primary and foreign keys in maintaining relational integrity.

Uploaded by

oracledb53
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

2025-01-24

9
System Analysis and Design
Course Code IT223
Faculty of Computing and Information Technology

Designing Databases

Dr. Mohammed Shobail


1

Introduction

2
FIGURE 9-1: Systems development life cycle with design phase highlighted

1
2025-01-24

Database Design
 File and database design occurs in two steps:
1. Develop a logical database model, which describes data using
notation that corresponds to a data organization used by a database
management system.
Relational database model

2. Prescribe the technical specifications for computer files and


databases in which to store the data.
Physical database design provides specifications
 Logical and physical database design in parallel with other system
design steps 3

Database Design (Cont.)

4
FIGURE 9-2: Example of conceptual, Logical and Physical data model for hotel reservations system

2
2025-01-24

The Process of Database Design


Four key steps in logical database modeling and design:
1. Develop a logical data model for each known user interface for the application using
normalization principles.

2. Combine normalized data requirements from all user interfaces into one consolidated
logical database model (view integration).

3. Translate the conceptual E-R data model for the application into normalized data
requirements.

4. Compare the consolidated logical database design with the translated E-R model and
produce one final logical database model for the application.
5

Physical Database Design


Key physical database design decisions include:
 Choosing a storage format for each attribute from the logical database
model.

 Grouping attributes from the logical database model into physical records.

 Arranging related records in secondary memory (hard disks and magnetic


tapes) so that records can be stored, retrieved and updated rapidly.

 Selecting media and structures for storing data to make access more
efficient. 6

3
2025-01-24

Deliverables and Outcomes


Logical database design
Must account for every data element on a system input or output
•Normalized relations are the primary deliverable.
Physical database design
Converts relations into database tables

•Programmers and database analysts code the definitions of the


database.
•Written in Structured Query Language (SQL) 7

Relational Database Model


Relational database model: data represented as a set of related tables or
relations
Relation: a named, two-dimensional table of data; each relation consists
of a set of named columns and an arbitrary number of unnamed rows

4
2025-01-24

Relational Database Model (Cont.)


Relations have several properties that distinguish them from nonrelational
tables:
Entries in cells are simple.
Entries in columns are from the same set of values.
Each row is unique.
The sequence of columns can be interchanged
without changing the meaning or use of the relation.
The rows may be interchanged or stored in any sequence.
9

Well-Structured Relation and Primary Keys


Well-Structured Relation (or table)
A relation that contains a minimum amount of redundancy
Allows users to insert, modify, and delete the rows without errors or inconsistencies
Primary Key
An attribute whose value is unique across all occurrences of a relation
All relations have a primary key.
This is how rows are ensured to be unique.
A primary key may involve a single attribute or be composed of multiple attributes.

10

5
2025-01-24

Normalization and Rules of Normalization


Normalization: the process of converting complex data structures
into simple, stable data structures
The result of normalization is that every nonprimary key attribute
depends upon the whole primary key.
First Normal Form (1NF)
Unique rows, no multivalued attributes
All relations are in 1NF

11

Normalization and Rules of Normalization(Cont.)

Second Normal Form (2NF)


Each nonprimary key attribute is identified by the whole key
(called full functional dependency)
Third Normal Form (3NF)
Nonprimary key attributes do not depend on each other (i.e. no
transitive dependencies)

12

6
2025-01-24

Normalization and Rules of Normalization(Cont.)

13
FIGURE 9-3: Normalization and Rules of Normalization

Functional Dependencies and Primary Keys

Functional Dependency: a particular relationship between two


attributes
For a given relation, attribute B is functionally dependent on
attribute A if, for every valid value of A, that value of A uniquely
determines the value of B.
The functional dependence of B on A is represented by A→B.

14

7
2025-01-24

Third Normal Form (3NF)


Foreign Key: an attribute that appears as a nonprimary key attribute in
one relation and as a primary key attribute (or part of a primary key) in
another relation
Referential Integrity: an integrity constraint specifying that the value
(or existence) of an attribute in one relation depends on the value (or
existence) of the same attribute in another relation

15

Third Normal Form (3NF)

16
FIGURE 9-4: Primary key, Foreign key and Referential Integrity

8
2025-01-24

Transforming E-R Diagrams into Relations

It is useful to transform the conceptual data model into a set of


normalized relations.
Steps
Represent entities.
Represent relationships.
Normalize the relations.

Merge the relations.

17

Representing Entities
 Each regular entity is transformed into a relation.
 The identifier of the entity type becomes the primary key of the
corresponding relation.
 The primary key must satisfy the following two conditions:
The value of the key must uniquely identify every row in the relation.
The key should be non redundant.
 The entity type label is translated into a relation name.

18

9
2025-01-24

Binary 1:N and 1:1Relationships


The procedure for representing relationships depends on both the
degree of the relationship—unary, binary, ternary—and the
cardinalities of the relationship.
 Binary 1:N Relationship is represented by adding the primary key
attribute (or attributes) of the entity on the one side of the
relationship as a foreign key in the relation that is on the many side
of the relationship.

19

Binary 1:N and 1:1Relationships (Cont.)

An attribute name is a noun and should be unique.


Binary or Unary 1:1 Relationship is represented by any of the
following choices:
Add the primary key of A as a foreign key of B.
Add the primary key of B as a foreign key of A.
Both of the above

20

10
2025-01-24

Binary and Higher-Degree M:N Relationships


Create another relation and include primary keys of all relations as primary key of new relation

21

Unary Relationships
Candidate key: an attribute (or combination of attributes) that uniquely
identifies each instance of an entity type
Unary 1:N Relationship
Is modeled as a relation
Primary key of that relation is the same as for the entity type
Foreign key is added to the relation that references the primary key values
Recursive foreign key: a foreign key in a relation that references the primary
key values of that same relation

22

11
2025-01-24

Unary Relationships(Cont.)
Unary M:N Relationship
Model as one relation, then
Create a separate relation to represent the
M:N relationship.
The primary key of the new relation is a
composite key of two attributes that both
take their values from the same primary key.
Any attribute associated with the
relationship is included as a non key attribute
in this new relation
23

Merging Relations

Purpose is to remove redundant relations


The last step in logical database design
Prior to physical file and database design

24

12
2025-01-24

View Integration Problems


Must understand the meaning of the data and be prepared to
resolve any problems that arise in the process
Synonyms: two different names used for the same attribute
When merging, get agreement from users on a single, standard
name.

25

View Integration Problems (Cont.)


Homonyms: a single attribute name that is used for two or more different
attributes.
Resolved by creating a new name
Dependencies between non keys— dependencies may be created as a result
of view integration
To resolve, the new relation must be normalized
Class/Subclass — relationships may be hidden in user views or relations
Resolved by creating a new name

26

13
2025-01-24

Physical File and Database Design

The following information is required:


Normalized relations, including volume estimates
Definitions of each attribute
Descriptions of where and when data are used, entered, retrieved, deleted, and
updated (including frequencies)
Expectations or requirements for response time and data integrity
Descriptions of the technologies used for implementing the files and database

27

Designing Fields

Field: the smallest unit of named application data recognized by system


software
Attributes from relations will be represented as fields
Data Type: a coding scheme recognized by system software for
representing organizational data

28

14
2025-01-24

Choosing Data Types

Selecting a data type balances four objectives:


Minimize storage space.

Represent all possible values of the field.


Improve data integrity of the field.

Support all data manipulations desired on the field.

29

Controlling Data Integrity


Default Value: a value a field will assume unless an explicit value is entered for
that field
Range Control: limits range of values that can be entered into field
Both numeric and alphanumeric data
Referential Integrity: an integrity constraint specifying that the value (or
existence) of an attribute in one relation depends on the value (or existence) of
the same attribute in another relation
Null Value: a special field value, distinct from zero, blank, or any other value,
that indicates that the value for the field is missing or otherwise unknown
30

15
2025-01-24

Designing Physical Tables


Relational database is a set of related tables.
Physical Table: a named set of rows and columns that specifies the
fields in each row of the table
Denormalization: the process of splitting or combining normalized
relations into physical tables based on affinity of use of rows and fields

31

Assignment
Define the following: ‫عرف التالي‬
E-R Diagram Referential Integrity

Relation Field

Primary Key Data type

Normalization Default Value

Foreign Key Null Value 32

16
2025-01-24

17

You might also like