0% found this document useful (0 votes)
12 views

Lesson2 Relational Model Data Types Normalization

The document provides an overview of relational databases and normalization. It defines key concepts like the relational data model, attributes, data types, and normalization. The goals of normalization include eliminating redundant data, non-key attributes determining key attributes, and tables being dependent on their primary key. The document discusses first normal form, which requires each cell to contain a single value and rows to be uniquely identifiable. An example shows how to add an order ID primary key to satisfy first normal form.

Uploaded by

osipashura
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lesson2 Relational Model Data Types Normalization

The document provides an overview of relational databases and normalization. It defines key concepts like the relational data model, attributes, data types, and normalization. The goals of normalization include eliminating redundant data, non-key attributes determining key attributes, and tables being dependent on their primary key. The document discusses first normal form, which requires each cell to contain a single value and rows to be uniquely identifiable. An example shows how to add an order ID primary key to satisfy first normal form.

Uploaded by

osipashura
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

COMP-20093

Information Management

LESSON2
Relational Model,
Data Types & Normalization
Learning Outcomes:
1. Demonstrate a thorough understanding of
a relational data model
2. Explain the different relational keys
3. Explain the use and importance of integrity
constraints
4. Enumerate the different data types used in
Microsoft Access
5. Apply the concept of normalization and its
importance in database design
6. Create fully normalized relations
Relational Data Model
Data Model – a collection of concepts that can be used
to describe a set of data, the operations to manipulate
the data, and a set of integrity rules for the data
 Represent data in the form of tables
 A named, two-dimensional table is called a
relation
 Each relation consists of named columns and
an arbitrary number of unnamed rows
 A named column is called an attribute
 Each row of a relation corresponds to a record
that contains data
Properties of a Relation
 Ithas a unique name
 No multivalued attributes are allowed

in a relation
 Each row is unique
 Each attribute has a unique name
 The sequence of columns as well as of

rows is insignificant
Classification of Attributes
 Required vs. Optional Attributes
Required – must have a value
Optional – may not have a value
 Simple vs. Composite Attributes

Simple (or atomic) - cannot be broken down into


smaller components
Composite – has meaningful component parts
 Single-valued vs. Multivalued Attributes

Single-valued – attribute which has only one


value
Multivalued Attributes – attribute that may take
on more than one value
Classification of Attributes
 Stored vs. Derived Attributes
Stored – value is provided by user
Derived – value is computed or derived
from another attribute/s
 Identifier – an attribute or combination of

attribute whose value distinguishes instances


of an entity type
 Must not change in value
 Must not be null
 Must be unique
Examples:
Classification of Attributes (for a given form for
an insurance application)
Required vs. Optional Attributes
Required – medical condition, attributes
pertaining to co-morbidities
Optional – provincial address
Simple vs. Composite Attributes
Simple (or atomic) - Age
Composite – Name, can be broken down into
first name, middle and last name
Examples:
Single-valued vs. Multivalued Attributes
Single-valued – Birthdate
Multivalued Attributes – Contact number (may
have more than 1 phone number)
Stored vs. Derived Attributes
Stored – Name
Derived – Age (can be derived from birthdate)
Identifier – an attribute or combination of
attribute whose value distinguishes instances of
an entity type - Account number (assigned by
the insurance company)
Data Types
Data Types
 Data types can seem confusing for
example, if a field's data type is Text,
it can store data that consists of either
text or numerical characters.
 But a field whose data type is Number

can store only numerical data. So, you


have to know what properties are used
with each data type.
A field's data type determines many other important
field qualities, such as the following

 Which formats can be used with the


field.
 The maximum size of a field value.
 How the field can be used in

expressions.
 Whether the field can be indexed.
 A field's data type can be predefined or you will
select a data type depending on how you create
the new field. For example, if you create a field
from the Datasheet view and:
 Use an existing field from another table, the data

type is already defined in the template or in the


other table.
 Enter data in a blank column (or field), Access

assigns a data type to the field based on the


values that you enter or you can assign the data
type and format for the field.
 On the Modify Fields tab, in the Fields &

Columns group, click Add Fields, Access displays


a list of data types that you can select from.
Format Use to display
Text Short, alphanumeric values, such as a last name
or a street address. Note, beginning in Access
2013, Text data types have been renamed
to Short Text.

Number, Large Number Numeric values, such as distances. Note that there
is a separate data type for currency.

Currency Monetary values.


Yes/No Yes and No values and fields that contain only one
of two values.
Date/Time, Date/Time Date/Time: Date and time values for the years
Extended 100 through 9999.
Date/Time Extended: Date and time values for the
years 1 through 9999.
Rich Text Text or combinations of text and numbers that
Format Use to display
Calculated Field Results of a calculation. The calculation must refer to other
fields in the same table. You would use the Expression Builder
to create the calculation. Note, Calculated fields were first
introduced in Access 2010.
Attachment Attached images, spreadsheet files, documents, charts, and
other types of supported files to the records in your database,
similar to attaching files to e-mail messages.
Hyperlink Text or combinations of text and numbers stored as text and
used as a hyperlink address.
Memo Long blocks of text. A typical use of a Memo field would be a
detailed product description. Note, beginning in Access 2013,
Memo data types have been renamed to Long Text.
Lookup Displays either a list of values that is retrieved from a table or
query, or a set of values that you specified when you created
the field. The Lookup Wizard starts and you can create a
Lookup field. The data type of a Lookup field is either Text or
Number, depending on the choices that you make in the
Number

Format Use to display

General Numbers without additional formatting exactly as


it is stored.

Currency General monetary values.

Euro General monetary values stored in the EU format.

Fixed Numeric data.

Standard Numeric data with decimal.

Percentage Percentages.

Scientific Calculations.
Date and Time
Format Use to display
Short Date Display the date in a short format. Depends on your
regional date and time settings. For example,
3/14/2001 for USA.
Medium Date Display the date in medium format. For example, 3-
Apr-09 for USA.
Long Date Display the date in a long format. Depends on you're
the regional date and time settings. For example,
Wednesday, March 14, 2001 for USA.
Time am/pm Display the time only using a 12 hour format that will
respond to changes in the regional date and time
settings.
Medium Time Display the time followed by AM/PM.
Time 24hour Display the time only using a 24 hour format that will
respond to changes in the regional date and time
settings
Yes/No

Data Type Use to display

Check Box A check box.

Yes/No Yes or No options

True/False True or False options.

On/Off On or Off options.


Field Size Property

 After you create a field and set its data type, you can
set additional field properties. The field's data type
determines which other properties that you can set. For
example, you can control the size of a Text field by
setting its Field Size property.

 For Number and Currency fields, the Field Size property


is especially important, because it determines the range
of field values. For example, a one-bit Number field
can store only integers ranging from 0 to 255.

 The Field Size property also determines how much disk


space each Number field value requires. Depending on
the field size, the number can use exactly 1, 2, 4, 8, 12,
or 16 bytes.
NORMALIZATION
NORMALIZATION
It is a technique of
organizing the data into multiple
related tables to minimize DATA
REDUNDANCY
Repetition of data increases
the size of the database.
 Optimizing table structures
Removing duplicate data entries
Process of efficiently organizing data in the
DB.
A technique for producing a set of relations
with desirable properties, given the data
requirements of an enterprise.
a formal method that identifies relations based
on their primary key and the functional
dependencies among their attributes.
NORMALIZATION
1ST, 2nd, 3rd Normal Form
1ST NORMAL FORM

• All rows be unique (no duplicate rows)


• Each cell must only contain a single
value (not a list)
• Each value should be non divisible
(can’t be split down further)
Problem 1
Customer Name Order
Marygin Sarmiento Burger, Fries, Coke
Sammy Sarmiento Nuggets, Lemonade, Fries
Christian Jay Sarmiento Burger, Fries, Coke
Problem 1- All rows must be uniquely
identifiable
Customer Name Order
Marygin Sarmiento Burger, Fries, Coke
Sammy Sarmiento Nuggets, Lemonade, Fries
Christian Jay Sarmiento Burger, Fries, Coke

Identical rows
Solution- Add an order ID as a primary key

OrderId Customer Name Order

1 Marygin Sarmiento Burger, Fries, Coke

2 Sammy Sarmiento Nuggets, Lemonade,


Fries
3 Christian Jay Sarmiento Burger, Fries, Coke
Problem 2- Each Cell must only contain a
single value
OrderId Customer Name Order

1 Marygin Sarmiento Burger, Fries, Coke

2 Sammy Sarmiento Nuggets, Lemonade, Fries

3 Christian Jay Burger, Fries, Coke


Sarmiento

Multiple Values
Solution: Create a separate table
with order items
OrderId Customer Name OrderId Item

1 Marygin Sarmiento 1 Burger

2 Sammy Sarmiento 1 Fries

1 Coke
3 Christian Jay
Sarmiento 2 Nuggets

2 Lemonade

2 Fries

3 Burger

3 Fries

3 Coke
Problem 3- All data must be atomic
(non divisible) – can’t be split down
further)
Orde Customer Name OrderId Item
rId
1 Burger
1 Marygin Sarmiento
1 Fries
2 Sammy Sarmiento
1 Coke
3 Christian Jay Sarmiento
2 Nuggets

2 Lemonade

2 Fries

3 Burger

3 Fries

3 Coke
Solution:

Order Last Name First Name OrderId Item


Id
1 Burger
1 Sarmiento Marygin
1 Fries
2 Sarmiento Sammy
1 Coke
3 Sarmiento Christian
2 Nuggets
Jay
2 Lemonade

2 Fries

3 Burger

3 Fries

3 Coke
2ND NORMAL FORM

Database must be in First


Normal Form
Non Partial dependency – All

non-prime attributes should


be dependent on the
candidate key
Example – No Partial Dependency
Student ID Course ID Course Fee
Composite Key
This Table is not in 2NF
1 1 500 because the course Fee is
only dependent on the
primary key to determine
1 2 1000 the course fee, you can do
it with just one column
2 4 200
(course ID)

2 3 750

3 5 1000

3 3 750
Example – No Partial Dependency
Student Courses Course Fees

Student ID Course ID Course Course Fee


Composite Key ID
1 1

1 2 1 500

2 1 2 1000

2 3 4 200

3 5 3 750

3 3 5 1000

3 750
3rd NORMAL FORM

 Database must be in First &


Second Normal Form
 No transitive dependency – all

fields must only be


determinable by the
primary/composite key, not by
other keys.
Third Normal Form
Composite Key
Tournament Name Year Winner Winners DOB

Indiana Invitational 1998 Al Fredrickson 21 July 1975

Cleveland Open 1999 Bob Abertson 28 September


1968
Bowling 1999 Faeng August 15,
Tournament Nepomuceno 1985
Des Moines 1999 Al Fredrickson 21 July 1975
Masters
9 Ball Tournament 1999 Efren Bata Reyes June 20, 1980

Indiana Invitational 1999 Chip Masterson 14 March 1977


Third Normal Form
Tournament Winners Winners DOB

Composite Key
Tournament Year Winner Winner Date of Birth
Name
Indiana 199 Al Al Fredrickson 21 July 1975
Invitational 8 Fredrickson
Cleveland 199 Bob Bob Abertson 28 September

Open 9 Abertson 1968

Bowling 199 Faeng Faeng August 15,

Tournament 9 Nepomucen Nepomuceno 1985

o Efren Bata June 20, 1980

Des Moines 199 Al Reyes

Masters 9 Fredrickson Chip 14 March 1977

9 Ball 199 Efren Bata Masterson


Activity # 3-Laboratory
Instructions:
Using the Table below, perform the process of normalization

You might also like