Chapter five
Physical Database Design Methodology for
Relational Database
We have established that there are three levels of database design:
• Conceptual: producing a data model which accounts for the relevant entities and relationships
within the target application domain;
• Logical: ensuring, via normalization procedures and the definition of integrity rules, that the
stored database will be non-redundant and properly connected;
• Physical: specifying how database records are stored, accessed and related to ensure adequate
performance.
It is considered desirable to keep these three levels quite separate -- one of Codd's
requirements for an RDBMS is that it should maintain logical-physical data independence. The
generality of the relational model means that RDBMSs are potentially less efficient than those
based on one of the older data models where access paths were specified once and for all at the
design stage. However the relational data model does not preclude the use of traditional
techniques for accessing data - it is still essential to exploit them to achieve adequate
performance with a database of any size.
We can consider the topic of physical database design from three aspects:
• What techniques for storing and finding data exist
• Which are implemented within a particular DBMS
• Which might be selected by the designer for a given application knowing the properties of
the data
Thus the purpose of physical database design is:
1. How to map the logical database design to a physical database design.
2. How to design base relations for target DBMS.
3. How to design enterprise constraints for target DBMS.
4. How to select appropriate file organizations based on analysis of transactions.
5. When to use secondary indexes to improve performance.
6. How to estimate the size of the database
7. How to design user views
8. How to design security mechanisms to satisfy user requirements.
Physical database design is the process of producing a description of the implementation of the
database on secondary storage.
Physical design describes the base relation, file organization, and indexes used to achieve
efficient access to the data, and any associated integrity constraints and security measures.
Sources of information for the physical design process include global logical data model
and documentation that describes model.
Logical database design is concerned with the what; physical database design is
concerned with the how.
The process of producing a description of the implementation of the database on
secondary storage.
Describes the storage structures and access methods used to achieve efficient access to
the data.
Steps in physical database design
1. Translate logical data model for target DBMS
1.1. Design base relation
1.2. Design representation of derived data
1.3. Design enterprise constraint
2. Design physical representation
2.1. Analyze transactions
2.2. Choose file organization
2.3. Choose indexes
2.4. Estimate disk space and system requirement
3. Design user view
4. Design security mechanisms
5. Consider controlled redundancy
6. Monitor and tune the operational system
Sql tutorials
The standard SQL commands to interact with relational databases are CREATE, SELECT,
INSERT, UPDATE, DELETE and DROP. These commands can be classified into the following
groups based on their nature.
DDL - Data Definition Language
DML - Data Manipulation Language
SQL-Constraints
Constraints are the rules enforced on data columns on a table. These are used to limit the
type of data that can go into a table. This ensures the accuracy and reliability of the data in
the database. Constraints can either be column level or table level. Column level constraints
are applied only to one column whereas, table level constraints are applied to the entire
table.
Following are some of the most commonly used constraints available in SQL:
NOT NULL Constraint: Ensures that a column cannot have a NULL value.
PRIMARY Key: Uniquely identifies each row/record in a database table.
FOREIGN Key: Uniquely identifies a row/record in any another database table.
Examples
To create table first we have to create database as follow
Create database College;
By using this database we can create table.
1. To create CUSTOMERS Table
CREATE TABLE CUSTOMERS (
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS VARCHAR (25),
PRIMARY KEY (ID)
);
2. To insert values into the table customer use insert INTO
statement.
Insert into CUSTOMERS values (01, “John”, 25, “Addis”);
Insert into CUSTOMERS values (02, “Aster”, 28, “Nazeriet”);
Insert into CUSTOMERS values (03, “Sosina”, 21, “Dessie”);
Insert into CUSTOMERS values (04, “Tokuma”, 30, “Awassa”);
3. Select statement
To see the value of the above table we are using SELECT
STATEMENT as the following.
Select * from CUSTOMERS;
ID Name Age address
01 John 25 Addiss
02 Aster 28 Nazeriet
03 Sosina 21 Dessie
04 Tokuma 30 Awassa
To select specific column SQL WHERE Clause is used.
Eg,. To select all data related to Aster, we use the following
command.
Select * from CUSTOMERS Where ID = 02;
ID Name Age address
02 Aster 28 Nazeriet
To update the age of Aster to 45, UPDATE statement is used.
Update CUSTOMERS set age = 45 where ID = 02
After this we can see by useing select * from CUSTOMERS command
and the result looks like as follow.
ID Name Age address
01 John 25 Addiss
02 Aster 45 Nazeriet
03 Sosina 21 Dessie
04 Tokuma 30 Awassa
To display only ID and Name:-
Select ID,Name from CUSTOMERS;
ID Name
01 John
02 Aster
03 Sosina
04 Tokuma
To delete John fro table customers;
Delete * from CUSTOMERS where ID = 01;
ID Name Age address
02 Aster 45 Nazeriet
03 Sosina 21 Dessie
04 Tokuma 30 Awassa
To arrange the table based on ID in descending order; we follow the following SQL
command.
Select * from CUSTOMERS order by ID DESC;
ID Name Age address
04 Tokuma 30 Awassa
03 Sosina 21 Dessie
02 Aster 45 Nazeriet
01 John 25 Addiss
To add column called “Sex”on existing CUSTOMERS table
ALTER command is used,
ALTER Table CUSTOMERS Add Sex varchar (6)
ID Name Age address Sex
04 Tokuma 30 Awassa
03 Sosina 21 Dessie
02 Aster 45 Nazeriet
01 John 25 Addiss
To delete entire table drop sql command is used( that means the table is
removed from the database)
DROP Table CUSTOMERS;
NB:- please review other Sql commands