ge “ACES
pee a < types of interface provided by a DBMS :
six '
thet? O70 & ased Interfaces for Browsing
oe
1, Ment pased Interfaces
jcal-User Interfaces
Language Interfaces
for Parametric Users
for the DBA
erfaces for Browsing : These interfaces present the user with lists of
that lead the user through the formulation of a request. Pull-down
options cued ng a very popular technique in window-based user interfaces. They are
menus ae DECC Sing interfaces, which allow a user to look through the contents of a
en used a exploratory and unstructured manner.
database inal : 7
ipased Interfaces : A form-based interfaces displays a form to each user. Users
Form BL of the form entries to insert new data, or they fill out only certain entries, in
a case ‘he DBMS will retrieve matching data for the remaining entries. Many DBMSs
w
wie forms specification languages special languages that help programmers specify such
B
forms. ‘ '
Graphical-User Interfaces : A Graphical User Interfaces (GUI) typically displays a
‘user in diagrammatic form. The user can then specify a query by manipulating
the diagram, In many cases, GUI utilize both menus and forms. Most GUI use a pointing
Mitjees such as a mouse, to pick certain parts of the displayed schema diagram.
Natural Language Interface : These interfaces accept requests written in English or
and” them. A natural language interface
some other language and attempt to “underst:
usually has its own “schema” which is similar to the database conceptual schema.
5. Interface
schema to the
Interfaces for Parametric Users : Parametric users, such as bank tellers, often have
must perform repeatedly system analyst and programmers, _
om ss
asmall set of operation that th
design and implement a special interface for a known class of naive users. Cc :
Interfaces for the DBA: Most database system contain privileged commands that can
bé used only by the DBA’s staff. These includes commands for creating accounts, setting
system parameters etc.
DATA DEFINITION LANGUAGE (DDL) (UPTU, 2004, 2006) (Im)
(tis a set of SQL commands used to create, modify and delete database structures byt
Notdata. These commands are normally not used by a general user, who should be accessing
the database tia., an application. They are normally used by th® DBA Yo a limited ex
base designer or application are immediate developer. ‘These statements are immediate,
ee net susceptible to Rollback commands. DDL also updates a special set of
ables called the data dictionary or data directory.
-Adata dictionary contains metadata, ie., data about data.
= iple of metadata. A database system consults the data
ifying actual data.Database Management System
Fundamental Commands of DDL:
The main tasks of the Date Definition Language are :
+ Tocreate the database 0! ables, Indexes etc.
+ To modify the databse objec we can chant
p or add a field from/to t
pjects like t
ge the data type of a field,
ts, for example,
he table.
we can dro}
» To destroy the database objects:
Creating Database Objects :
tase the CREATE statement. For example :
For creating database objects We
tax : SQL > CREATE TABLE < table Name > (fieldname, Datatype, (width,
fieldname, Datatype (width), ----); .
Example: SQL > CREATE TABLE STUDENT (NAME VARCHAR, (12)
(2, 0), ADDRESS VARCHAR, (10), Class Number (2, 0));
Output: Table Created.
This creates a table of students hi
), AGE-NUMBE
aving field namne, age, address and class:
ription of Table
d field width by “describ
De
Tris possible to obtain description o
f table to know field ant
command.
Syntax: SQL> DESCRIBE Tablename; OR DESC Tablename;
Example: SQL> DESCRIBE STUDENT; -
Output:
TYPE
NAME VARCHAR2(12)
AGE NUMBER(2)
aa VARCHAR2(10) ~
SS NUMBER(2)
‘This describes the database of student,
Creating table using Constraint
Example: SQL > CREATE TABLE Dept.
(deptno.NUMBER(2) PRIM ;
ARYKEY, D B
VARCHAR2(25) CHECK (LOC IN (‘Delhi’, Dosa Noidemaeeede 10) NOTNULL, LO
In the abov ‘ Q
The oat al » Dept, table has three Sgldanamel
cola ee “aul accept the number type Ee dept.no, dname and lo
Enlehis to be stor a we have tolenter the ni er ot
department stored ih the datgpgses the. Hea ueeth fo
partment wll je havinga valid name, We Se eas pulmet
’ ri ey < i
obser ena her cos vhs
‘Noida’. Any value of other thai a ese tht
n these
Cons'
department,
that every new
NULL. The last co!
three locations nam
will not be accepted.Introduction to DEMS: er
sarative Date Integrity UNTRUE No duphicney. bot
Bee ene are 100 (YDES of data Integrities; NULLA
anu PRIMARY Mo dtep,No Nou
“patil
' PAULI Specifics default vale, NOT NUM ~ Pupticacy, pur
at
ia NOTNULL = Specifies that value should not be null not nut
iq UNIQUE ~ Specifies that vale should be unique.
CHECK - Specifies that values should be eheeked,
(@
2, Referential ;
(a) PRIMARY KEY ~The field is Primary field,
(b) FOREIGN KEY ~
(gq DELETE/UPDATE Restrict ~
NULL Value Concept
NULL Value Concer
iva particular row do not contain a data, then it may be treated as null value,
Column of any data type may contain NULL unless, the column was defined as NOT
NULL, When table was created.
NOT NULL
Ifa column is defined as NOT NULL, then it becomes a mandatory column ie., the user
nas to enter the data into it. It can take duplicate values if it is not a unique column but
annot take NULLS.
Example : SQL > CREATE TABLE Emp (EMP_NO VARCHAR2(2} NOT NULL);
rimary Key
primary key is a one or more column used to uniquely identify each row in the table]
hese values should never be changed and should never be NULL. Through this key, rows
Tthe table are individually identified. NULLS are not allowe’ in the primary key column.
he important point about primary key is t nly one primary key per table is allowed.
he reason may be that the important task which the primary key. performs is to uniquely
lentify the row. — =
_ Example : SQL > CREATE TABLE Emp (emp_no VARCHAR2(2) Primary Key);
. ip (emp.
In this case Emp_no is primary key.
nique Key
mate Key
This is similar to primary key. It is used to ensures that information in the colu!
ch record in unique.
feample : SQL > CREATE TABLE Emp (emp_no VARCHAR2(2) Constraint (Uniquel}:
in this case emp_no is unique key.
fault Value
ne
ymin for
Wi 7 Fi
hen the cell is created, default value can be assigned to it as below.
pample : SQL > CREATE TABLE Emp (emp_no VARCHAR2(2) Default 0)
inthis case default value of emp_no is 0.Foreign Key :
aa key represents the relationships between aed El ca Refereng
ix ae A rgein y ClN Te can lao Be used elcid
mae ie Sete or prrespondin g primary key value in the primary key table to nae
a meaning. A foereign key value can be left nul
~ REFERENCES emp 1;
key in emp table is Foreign key.
1. It is inserted by.
In this case the Reference
Check Constraints
of the name data entered.
These constraints can be inserted to check integrity
syntax : CONSTRAINT CHECK (Logical Expression)
Example : SQL> CONSTRAINT CHECK (NAME LIKE “M%);
an be declared at the time of creations of table.
The constraint c
Example of Constraints =
SQL > CREATE TABLE LOANS (
account NUMBER (6, 0) NOT NULL,
Loan_number NUMBER (6, 0) NOT NULL UNIQUE,
Loan_type VARCHAR2(8)
CONSTRAINT Loan_type
in (PERS’, ‘HOME’, ‘AUTO}),
amount NUMBER (8, 0) NOT NULL,
Loan_Date DATE DEFAULT SYSDATE);
Creating Index
Indexes are used to speed up the retrieval of records in response to certain seard
condition. The index structure provides the alternative way of accessing the records withot
affecting the physical, placement of records on physical media, The index is construct’
based on a column or a group of columns from the table. When this index is used in
query for searching the records, it retrives the information in an efficient manner.
The Syntax
QL > CREATE [UNIQUE] INDEX ON CREATE INDEX Empno_index ON emp (emp no);
Modifying the table :
To change the definition of a table, we have to
three clauses ADD, MODIFY and DROP, which page cae tne
+ Add a new column ,
+ Add a new constraint
* Modify acolumn
+ Modify a constraintropacolumn
Introduction to DBMS CE
+ Drop "constraint
ac
: at SOL > ALTER TABLE
(ADD/MODIFY/DROP; (column
tex! A
spection $QL> ALTER TABLE emp ADD (Commission NUMBER (7, 2);
2 TER TABLE EMP MODIFY (Commission NUMBER (8, 2));
9. LTER TABLE emp DROP COLUMN Commission;
anc an object (table/view)
ie DROP Command is used to drop an object permanently.
tag: SQL> DROP TABLE