Unit V
Unit V
UNIT-V
Database
All modern database management systems like SQL, MS SQL Server, IBM DB2, ORACLE, My-SQL, and Microsoft Access
are based on RDBMS.
It is called Relational Database Management System (RDBMS) because it is based on the relational model introduced by
E.F. Codd.
How it works
Data is represented in terms of tuples (rows) in RDBMS.
A relational database is the most commonly used database. It contains several tables, and each table has its
primary key.
Due to a collection of an organized set of tables, data can be accessed easily in RDBMS.
Structured Query Language (SQL)
Structured Query Language is a standard Database language that is used to create, maintain, and
retrieve the relational database.
SQL is case insensitive. But it is a recommended practice to use keywords (like SELECT, UPDATE,
CREATE, etc.) in capital letters and use user-defined things (like table name, column name, etc.) in
small letters.
We can write comments in SQL using “–” (double hyphen) at the beginning of any line. SQL is the
programming language for relational databases (explained below) like MySQL, Oracle, Sybase, SQL
Server, Postgre, etc.
Some of The Most Important SQL Commands
● SELECT - extracts data from a database
● UPDATE - updates data in a database
● DELETE - deletes data from a database
● INSERT INTO - inserts new data into a database
● CREATE DATABASE - creates a new database
● ALTER DATABASE - modifies a database
● CREATE TABLE - creates a new table
● ALTER TABLE - modifies a table
● DROP TABLE - deletes a table
● CREATE INDEX - creates an index (search key)
● DROP INDEX - deletes an index
A relational database means the data is stored as well as retrieved in the form of relations (tables). Table 1 shows
the relational database with only one relation called STUDENT which stores ROLL_NO, NAME, ADDRESS,
PHONE, and AGE of students.
STUDENT Table
Important Terminologies
These are some important terminologies that are used in terms of relation.
● Attribute:Attributes are the properties that define a relation. e.g.; ROLL_NO, NAME
etc.
● Tuple:Each row in the relation is known as tuple. The above relation contains 4
tuples, one of which is shown as:
● Data Definition Language:It is used to define the structure of the database. e.g; CREATE TABLE, ADD
COLUMN, DROP COLUMN and so on.
● Data Manipulation Language:It is used to manipulate data in the relations. e.g.; INSERT, DELETE,
UPDATE and so on.
● Data Query Language:It is used to extract the data from the relations. e.g.; SELECT So first we will
consider the Data Query Language. A generic query to retrieve from a relational database is:
➔ [WHERE condition]
➔ [ORDER BY(Attributes)[DESC]];
Different Query Combinations
Case 1: If we want to retrieve attributes ROLL_NO and NAME of all students, the query will be:
SELECT ROLL_NO, NAME FROM STUDENT;
Case 2: If we want to retrieve ROLL_NO and NAME of the students whose ROLL_NO is greater than 2, the query will be:
SELECT ROLL_NO, NAME FROM STUDENT
WHERE ROLL_NO>2;
CASE 3: If we want to retrieve all attributes of students, we can write * in place of writing all attributes as:
SELECT * FROM STUDENT
WHERE ROLL_NO>2;
CASE 4: If we want to represent the relation in ascending order by AGE, we can
use ORDER BY clause as:
SELECT * FROM STUDENT ORDER BY AGE;
DBMS Architecture 1-level, 2-Level, 3-Level
A Database store a lot of critical information to access data quickly and securely. Hence it
is important to select the correct architecture for efficient data management. DBMS
Architecture helps users to get their requests done while connecting to the database. We
choose database architecture depending on several factors like the size of the database,
number of users, and relationships between the users
● 1-Tier Architecture
● 2-Tier Architecture
● 3-Tier Architecture
1-Tier Architecture
In 1-Tier Architecture the database is directly available to the user, the user can directly sit on the DBMS and
use it that is, the client, server, and Database are all present on the same machine.
Advantages of 1-Tier
Architecture
The 2-tier architecture is similar to a basic client-server model. The application at the client end directly communicates
with the database on the server side. APIs like ODBC and JDBC are used for this interaction. The server side is
responsible for providing query processing and transaction management functionalities. On the client side, the user
interfaces and application programs are run. The application on the client side establishes a connection with the server
side in order to communicate with the DBMS.
Advantages of 2-Tier Architecture
● Easy to Access: 2-Tier Architecture makes easy access to the database, which makes
fast retrieval.
● Scalable: We can scale the database easily, by adding clients or by upgrading hardware.
● Low Cost: 2-Tier Architecture is cheaper than 3-Tier Architecture and Multi-Tier
Architecture.
● Easy Deployment: 2-Tier Architecture is easy to deploy than 3-Tier Architecture.
● Simple: 2-Tier Architecture is easily understandable as well as simple because of only
two components.
3-Tier Architecture
The data in a MySQL database are stored in tables. A table is a collection of related data, and it consists of
columns and rows.
Databases are useful for storing information categorically. A company may have a database with the
following tables:
● Employees
● Products
● Customers
● Orders
Introduction to PHP MyAdmin
● phpMyAdmin is an open-source software tool introduced on September 9, 1998, which is
written in PHP.
● Basically, it is a third-party tool to manage the tables and data inside the database.
phpMyAdmin supports various type of operations on MariaDB and MySQL.
● The main purpose of phpMyAdmin is to handle the administration of MySQL over the
web.
● It is the most popular application for MySQL database management.
● We can create, update, drop, alter, delete, import, and export MySQL database tables by
using this software.
● phpMyAdmin also supports a wide range of operation like managing databases,
relations, tables, columns, indexes, permissions, and users, etc., on MySQL and
MariaDB.
● These operations can be performed via user interface, while we still have the ability to
execute any SQL statement.
Features of phpMyAdmin
phpMyAdmin supports several features that are given below:
○ phpMyAdmin can create, alter, browse, and drop databases, views, tables, columns, and indexes.
○ It can display multiple results sets through queries and stored procedures.
○ phpMyAdmin use stored procedure and queries to display multiple results sets.
○ It supports foreign keys and InnoDB tables.
○ phpMyAdmin can track the changes done on databases, views, and tables.
○ We can also create PDF graphics of our database layout.
○ It supports mysqli, which is the improved MySQL extension.
○ phpMyAdmin can interact with 80 different languages.
○ phpMyAdmin can edit, execute, and bookmark any SQL-statements and even batch-queries.
○ By using a set of pre-defined functions, it can transform stored data into any format. For example - BLOB-
data as image or download-link.
○ It provides the facility to backup the database into different forms.
Advantage of phpMyAdmin
Web server - phpMyAdmin's interface is based on our web browser, we need a web server to
keep phpMyAdmin's files inside it. Apache and IIS are popular web servers. We can download
Apache web server from here http://mirrors.estointernet.in/apache//httpd/.
PHP - We also need to install PHP 5.3 or upper version to support different functionalities. It contains different
extensions to provide support for these functionalities. For example -
Web Browser - Web browser is required to access phpMyAdmin with enabled cookie and JavaScript. It can be
Chrome, Internet Explorer, etc.
END
Syllabus completed
ALL THE BEST FOR EXAMS