Académique Documents
Professionnel Documents
Culture Documents
07/07/08
DATABASES
Contents
1. Introduction to Database
• Text File
• Spread Sheet
• Relational Database
2. Data Types
• Numeric
• String
3. Introduction to Normalization
• Why Normalize
4. Introduction to SQL
5. Q & A
What is a Database?
A database is a collection of data.
1 Martin 1 1
2 Laxmikant 1 1
3 Deepali 1 1
Deparment Company
ID Name ID Name
1 PHP 1 VSplash
2 HR
3 Design
Data Types
Numeric
Date and time
String
Numeric
TINYINT( ) -128 to 127 normal
0 to 255 UNSIGNED.
YEAR[(2|4)] 1901 to 2155, and 0000 / 70 to 69
String
CHAR( ) A fixed section from 0 to 255 characters long.
VARCHAR( ) A variable section from 0 to 255 characters long.
TINYTEXT A string with a maximum length of 255 characters.
TEXT A string with a maximum length of 65535 characters.
BLOB A string with a maximum length of 65535 characters.
MEDIUMTEXT A string with a maximum length of 16777215
characters.
MEDIUMBLOB A string with a maximum length of 16777215
characters.
LONGTEXT A string with a maximum length of 4294967295
characters.
LONGBLOB A string with a maximum length of 4294967295
characters.
Why Normalize?
Flexibility
• Structure supports many ways too look
at the data
Data Integrity
• Modification Anomalies
Deletion
Insertion
Update
• Efficency
Eliminate redundant data and save space
Normalization Defined
“In relational database design, the process
of organizing data to minimize duplication”
Normalization usually involves dividing a
database into two or more tables and
defining relationships between tables
The objective is to isolate data so that
additions, deletions, and modifications of a
field can be made in just one table and
then propagated through the rest of the
database via the defined relationships
Normal Forms
A series of logical steps to take to
normalize data tables
First Normal Form
Second Normal Form
Third Normal Form
First Normal Form
All columns (fields) must be atomic
• Means: no repeating items in columns
Order Data Customer Items
06/07/2008 Martin Hammer,Saw,Nails
Orders OrderDetails
OrderId OrderId
CustomerId Item
OrderDate
Third Normal Form
In 2NF and every non-key column is mutually
independent
• Means: Calculations
Item Quantity Price Total
Hammer 2 10 20
Saw 5 40 200
Nails 8 1 8
OrderDetails
OrderId Put expression in text controll or in query:
Item =Quantity * Price
Quantity
Price
SQL (Structured Query Language)
SQL is a standard interactive and
programming language for querying and
modifying data and managing databases