Class 2
Class 2
unit I
SQL
• Structured Query Language (SQL), as we all know,
is the database language by which we can perform
certain operations on the existing database, and we can
also use this language to create a database.
These SQL commands are mainly categorized into five
categories:
1.DDL – Data Definition Language
2.DQL – Data Query Language
3.DML – Data Manipulation Language
4.DCL – Data Control Language
5.TCL – Transaction Control Language
• Data Definition Language actually consists of the SQL
commands that can be used to define the database
schema. It simply deals with descriptions of the
database schema and is used to create and modify the
structure of database objects in the database.
Command Description Syntax
Create database or its
CREATE TABLE table_name
objects (table, index,
CREATE (column1 data_type, column2
function, views, store
data_type, ...);
procedure, and triggers)
Delete objects from the
DROP DROP TABLE table_name;
database
ALTER TABLE table_name ADD
Alter the structure of the
ALTER COLUMN column_name
database
data_type;
Remove all records from a
table, including all spaces
TRUNCATE TRUNCATE TABLE table_name;
allocated for the records are
removed
SELECT column1,
It is used to retrieve
column2, ...FROM
SELECT data from the
table_name<br>WHE
database
RE condition;
REVOKE privilege_name
ON object_name
FROM {user_name |PUBLIC |role_name}
REVOKE SELECT ON employee FROM user1;
Privileges and Roles:
Privileges: Privileges defines the access rights provided
to a user on a database object. There are two types of
privileges.
1) System privileges - This allows the user to CREATE,
ALTER, or DROP database objects.
2) Object privileges - This allows the user to EXECUTE,
SELECT, INSERT, UPDATE, or DELETE data from database
objects to which the privileges apply.
DBMS ARCHITECTURE
• 1-Tier Architecture
In this architecture, the database is directly available to
the user. It means the user can directly sit on the DBMS
and uses it.
• 2-Tier Architecture
The 2-Tier architecture is same as basic client-server. In
the two-tier architecture, applications on the client end
can directly communicate with the database at the
server side. For this interaction, API's
like: ODBC, JDBC are used.
• 3-Tier Architecture
• The 3-Tier architecture contains another layer between
the client and server. In this architecture, client can't
directly communicate with the server.
• The application on the client-end interacts with an
application server which further communicates with the
database system.
• Internal Level
• The internal level has an internal schema which
describes the physical storage structure of the
database.
• The internal schema is also known as a physical
schema.
• It uses the physical data model. It is used to define that
how the data will be stored in a block.
• The physical level is used to describe complex low-level
data structures in detail.
Conceptual Level
• The conceptual schema describes the design of a
database at the conceptual level. Conceptual level is
also known as logical level.
• The conceptual schema describes the structure of the
whole database.
• The conceptual level describes what data are to be
stored in the database and also describes what
relationship exists among those data.
• In the conceptual level, internal details such as an
implementation of the data structure are hidden.
• Programmers and database administrators work at this
level.
• External Level
At the external level, a database contains several
schemas that sometimes called as subschema. The
subschema is used to describe the different view of the
database.
An external schema is also known as view schema.
Each view schema describes the database part that a
particular user group is interested and hides the
remaining database from that user group.
The view schema describes the end user interaction with
database systems.