INTRODUCTION TO DATABASE Lecture #2
SYSTEMS Ketevan Grigalashvili
THE RELATIONAL DATABASE MODEL
A relational database (RDB) is a way of structuring
information in tables, rows, and columns. An RDB has
the ability to establish links—or relationships–
between information by joining tables, which makes
it easy to understand and gain insights about the
relationship between various data points.
It was developed by E.F. Codd from IBM in the
1970s.
WHAT IS DATABASE NORMALIZATION
Normalization is the process of designing database
tables in a way that makes for efficient use of disk
space and that allows the efficient manipulation and
updating of the data.
PRINCIPLES OF DATABASE
NORMALIZATION
• Elimination of Data Redundancy
• Ensuring Data Consistency
• Simplification of Data Management
• Improved Database Design
• Avoiding Update Anomalies
• Standardization
FIRST NORMAL FORM (1NF)
• Eliminate repeating groups in individual tables
• Create a separate table for each set of related data
• Identify each set of related data with a primary key
(Primary Key ensures that there are no duplicate rows and that
each record is uniquely identifiable)
SECOND NORMAL FORM (2NF)
• Create separate tables for sets of values that apply to multiple records
• Relate these tables with a foreign key
(Foreign Key ensures referential integrity between two tables)
A table is in Second Normal Form (2NF) if It is already in First Normal Form.
THIRD NORMAL FORM (3NF)
• Eliminate fields that don't depend on the key
A table must already be in Second Normal Form (2NF) before it
can qualify for Third Normal Form (3NF).
CREATING A DATABASE WHILE FOLLOWING
NORMALIZATION PRINCIPLES
• Identify entities and attributes
• Use all the normalization forms
• Assign primary keys to the tables
• Assign foreign keys to the tables
What is Entity? An entity in a database represents a real-world object or
concept that can be uniquely identified and stored as data.
What is Attribute? An attribute is a property or characteristic of an entity in a
database.
DATABASE MANIPULATION COMMANDS
Creating the database:
CREATE DATABASE database_name
Dropping (deleting) the database:
DROP DATABASE database_name
TABLE MANIPULATION COMMANDS
Creating the table:
CREATE TABLE table_name
(column_1 data_type [NULL/NOT NULL],
column_2 data_type [NULL/NOT NULL] ,
.......
)
Dropping (deleting) the table:
DROP TABLE table_name
TABLE MANIPULATION COMMANDS
Adding a new field to the table:
ALTER TABLE table_name
ADD column_name data_type [NULL/NOT NULL]
Modifying an existing field in the table:
ALTER TABLE table_name
ALTER COLUMN column_name data_type [NULL/NOT NULL]
Deleting/dropping an existing field from the table:
ALTER TABLE table_name
DROP COLUMN column_name