0% found this document useful (0 votes)
227 views16 pages

RDBMS Notes

The document discusses relational database management systems and SQL. It covers topics like data vs information, database architecture, schema vs instance, SQL commands categories (DDL, DML, DQL, DCL, TCL), examples of DDL commands like CREATE and ALTER, DML commands like INSERT and UPDATE, DQL SELECT command, constraints to ensure data validity. Functions and operators are also mentioned. The document provides information on the basic concepts and components of relational database systems and SQL language.

Uploaded by

Urmi Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
227 views16 pages

RDBMS Notes

The document discusses relational database management systems and SQL. It covers topics like data vs information, database architecture, schema vs instance, SQL commands categories (DDL, DML, DQL, DCL, TCL), examples of DDL commands like CREATE and ALTER, DML commands like INSERT and UPDATE, DQL SELECT command, constraints to ensure data validity. Functions and operators are also mentioned. The document provides information on the basic concepts and components of relational database systems and SQL language.

Uploaded by

Urmi Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Relational Database Management Systems (4330702)

URMI UDITI DIPTI YASHVI MANSI LADANI

⮚ DATA v/s INFORMATION:


⮚ DATABSE:
⮚ DATABASE MANAGEMENT SYSTEM:
⮚ DATABASE ENVIRONMENT:
⮚ ANSI/SPARC 3 tier Database Architecture:

⮚ SCHEMA vs INSTANCE:
⮚ METADATA:
⮚ DATA DICTIONARY:
⮚ SYSTEM CATELOG:

⮚ Structured Query Language (SQL) as we all know is the database language by the use of
which we can perform certain operations on the existing database and also we can use this
language to create a database. SQL uses certain commands like Create, Drop, Insert, etc. to
carry out the required tasks.
⮚ These SQL commands are mainly categorized into following categories as:

SQL
COMMANDS

DDL(Data DML(Data DQL(Data DCL(Data TCL(Transacti


Definition Manipulation Query Control on Control
Language) Language) Language) Language) Language)

⮚ VARIOUS DDL COMMANDS


● DDL or Data Definition Language actually consists of the set of SQL commands that can
be used to create, modify and delete the structure of database objects in the database.
● It simply deals with descriptions of the database schema.
● Example of DDL commands are as follows:

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

DDL
COMMANDS

CREATE DESC ALTER RENAME DROP TRUNCATE

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

⮚ CREATE Command:
● The CREATE TABLE statement is used to create a new table in a database.
● A table name should be Unique.
● Each column has minimum three attributes: Name, Data type and Size for that column.

Syntax:

CREATE table tableName


(ColumnName1 datatype (size),
columnName2 datatype (size),
.
.
.
columnNameN datatype(size)
);

● A table name and column name must start with alphabet, must not match with reserved
keywords, and it can be combination of A-Z, a-z, 0-9, and '_' (underscore) having
maximum length up to 30 characters.
● Each column definition is separated by from other by a ‘,' (comma).
● The entire SQL statement is terminated with ' ; ' (semi colon).

Example: Create a ‘Faculty’ table having columns (FacultyName, Department and Experience) as
described below:

Column
Datatype Size
Name

F_Name Varchar2 30

F_Dept Varchar2 15

Experience Number 2

Input command:

Create table Faculty (F_Name varchar2(30), F_Dept varchar2(15), Experience number(2));

Output:

Table Created.

⮚ DESC or DESCRIBE:
● Once the table is created, there is a need to verify whether a table has been created
according to requirements. For this purpose ‘describe’ command can be used as follow:

Syntax:

DESC tableName;

OR

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

DESCRIBE tableName;

Input Command:

SQL> desc faculty;

Output:

Name Null? Type

----------------------------------------- -------- ----------------------------

FACULTYNAME VARCHAR2(20)

DEPARTMENT VARCHAR2(20)

EXPERIENCE NUMBER(2)

⮚ ALTER command:

⮚ RENAME command:

⮚ DROP command:

⮚ TRUNCATE command:

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

⮚ Various DML commands:

DML
COMMANDS

INSERT UPDATE DELETE

⮚ INSERT command:

⮚ UPDATE command:

⮚ DELETE command:

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

⮚ DQL COMMAND:

⮚ SELECT command:

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

⮚ TCL COMMANDS:

TCL
COMMANDS

COMMIT ROLLBACK SAVEPOINT

⮚ COMMIT command:
o Implicit commit

o Explicit commit

⮚ SAVEPOINT:

⮚ ROLLBACK:

o Complete rollback

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

o Partially rollback

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

⮚ DCL COMMANDS:

DCL
COMMANDS

GRANT REVOKE

⮚ GRANT command:

⮚ REVOKE command:

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

⮚ OPERATORS:
⮚ FUNCTIONS:
o Aggregate:
o Scalar:
▪ Number
▪ Character
▪ Date
▪ Conversion

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

Constraints:
SQL constraints are used to specify rules for the data in a table. Constraints are used to limit
the type of data that can go into a table.
Ensures validity, correctness and to consistency of data in a database.

NOT NULL
Domain integrity
constraints
Check
Constraints

Entity Integrity
Primary Key
Key Constraints
Unique Key
Referencial Foreign key
Integrity constraint

Entity Integrity:
Restricts the values in row of an individual table.
Domain:
Unique set of values that can be assigned to an attribute in a database.
Domain Integrity: NOT NULL, CHECK
Specifies that the value of each column must belong to the domain of that column.
KEY Constraints: Primary Key, Unique Key
Ensures that there must be some way to distinguish two different rows of the same table
uniquely.
Referential Integrity: Foreign Key
Specifies that a row in one table that refers to an existing row of another table.
Requires that values in a foreign key column must either be present in the primary key that
is referenced by the foreign key.

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

NOTE: Constraints can be applied using CREATE TABLE statement while creating a new table
or using ALTER TABLE statement to modify or add constraints in an existing table.

Level of Constraints
Column Level
Defined along with column definition

Table Level
Defined after defining all the columns of a table
NOT NULL constraint is "not allowed" to defined at table level

Keys:
A key in DBMS is an attribute or a set of attributes that help to uniquely identify a tuple (or
row) in a relation (or table).

Key Attribute Minimal number of attribute(s) which uniquely identifies all records in a
relation

Candidate If no. of key attributes >1 then all are called candidate keys
Key

Primary Key From candidate key(s) any 1 choosen by database designer as primary key

Alternate Candidate key(s) not choosen as primary key by database designer


Key

Unique Key Same as primary key but allows NULL value

Super Key Super set of all key(s). All possible combination of attribute(s) which uniquely
identifies all records in a relation

Composite If more than one attributes combinely form a key


Key
Foreign Key One or more attributes whose values derived from the key attribute of
another relation(s)

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

Example:
Student:

Enrollment First_Name Last_Name DOB VoterID UID

216150307001. Neha Patel 12-DEC-01 95132 54654635

216150307002. Urmi Shah 15-JAN-02 54564 78743513

216150307003. Dhvani Surti 01-MAR-05 97164 35323565

216150307004. Shruti Mishra 29-JUL-03 85965 43456496

216150307005. Dhvani Surti 14-NOV-02 14275 65745674

216150307006. Dhruti Shah 24-FEB-04 23265 15456455

216150307007. Neha Rathod 12-DEC-01 78975 48658715

Key Attributes:
KA1: Enrollment
KA2: VoterID
KA3: UID
KA4: Last_Name, DOB
KA Set: {Enrollment, VoterID, UID, (Last_Name, DOB) }
CK = KA Set
PK= Any 1 KA is selected from KA Set (eg. PK = Enrollment)
AK Set= CK – PK (eg. AK Set = { VoterID, UID, (Last_Name, DOB)}

GGP, Surat (DCE)


Relational Database Management Systems (4330702)
URMI UDITI DIPTI YASHVI MANSI LADANI

GGP, Surat (DCE)

You might also like