0% found this document useful (0 votes)
33 views34 pages

2.1 Fundamentals of RDBMS

Uploaded by

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

2.1 Fundamentals of RDBMS

Uploaded by

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

Database Management System

FUNDAMENTALS OF RDBMS

Presented by

ASHWINI N INGLE
Department of Information Technology
Govt. Polytechnic Amravati

1
Learning outcomes
• In this Topic , you will learn
• About the relational database management
system
• What is table, fields, records?
• Data types
• Concept of RDBMS

2
RDBMS
• A Relational database management system (RDBMS)
is a database management system (DBMS) that is
based on the relational model as introduced by E. F.
Codd.
• RDBMS stands
For Relational Database Management System.
RDBMS is the basis for SQL, and for all modern
database systems like MS SQL Server, IBM DB2,
Oracle, MySQL, and Microsoft Access.

The data in RDBMS is stored in database objects
called tables.
3
Different RDBMS Technology

4
What is a table?

• The data in an RDBMS is stored in


database objects which are called
as tables.
• This table is basically a collection of
related data entries and it consists of
numerous columns and rows.

5
CUSTOMER TABLE

STUDENT TABLE

6
FIELDS, RECORDS OR ROW

• Every table is broken up into smaller entities


called fields. The fields in the CUSTOMERS table
consist of ID, NAME, AGE, ADDRESS and
SALARY.
• A field is a column in a table that is designed to
maintain specific information about every record
in the table.
• A record is also called as a row of data is each
individual entry that exists in a table.
• For example, there are 7 records in the above
CUSTOMERS table.

7
• Following is a single row of data or record in
the CUSTOMERS table −

• A record is a horizontal entity in a table.

8
• A column is a vertical entity in a table that
contains all information associated with a
specific field in a table.
• For example, a column in the CUSTOMERS
table is ADDRESS, which represents location
description and would be as shown below −

9
NULL
• A NULL value in VALUE
a table is a value in a field
that appears to be blank, which means a field
with a NULL value is a field with no value.
• It is very important to understand that a NULL
value is different than a zero value or a field
that contains spaces. A field with a NULL
value is the one that has been left blank during
a record creation.

10
E.F. Codd’s 12 Rules for RDBMS
• Dr E.F.Codd, also known to the world as the
‘Father of Database Management Systems’ had
propounded 12 rules which are in-fact 13 in
number.
• The rules are numbered from zero to twelve.
According to him, a DBMS is fully relational
if it abides by all his twelve rules.

11
• Rule 0 − Foundation rule
The system must qualify as relational as a database
and as a management system.
For a system to qualify as a RDBMS that system
must use its relation facilities to manage database.

• Rule 1 − Rule of Information


Relational Databases should store the data in the
form of relations. Tables are relations in Relational
Database Management Systems. Be it any user
defined data or meta-data, it is important to store the
value as an entity in the table cells.

12
E.F. Codd’s 12 Rules for RDBMS
• Rule 2 − Rule of Guaranteed Access
The use of pointers to access data logically is strictly forbidden.
Every data entity which is atomic in nature should be accessed
logically by using a right combination of the name of table,
primary key represented by a specific row value and column
name represented by attribute value.
• Rule 3 − Rule of Systematic Null Value Support
Null values are completely supported in relational databases.
They should be uniformly considered as ‘missing information’.
Null values are independent of any data type. They should not be
mistaken for blanks or zeroes or empty strings. Null values can
also be interpreted as ‘inapplicable data’ or ‘unknown
information.

13
EXAMPLE
CUSTOMER TABLE

USER 1 WANTS DATA OF CUSTOMER 🡪 ID, SALARY

USER 2 🡪 ID, NAME, SALARY

14
E.F. Codd’s 12 Rules for RDBMS
• Rule 4 − Rule of Active and online relational Catalog
In the Database Management Systems lexicon, ‘metadata’ is
the data about the database or the data about the data.
The active online catalog that stores the metadata is called
‘Data dictionary’. The so called data dictionary is accessible
only by authored users who have the required privileges and
the query languages used for accessing the database should be
used for accessing the data of data dictionary.
• Rule 5 − Rule of Comprehensive Data Sub-language
A single robust language should be able to define integrity
constraints, views, data manipulations, transactions and
authorizations. If the database allows access to the
aforementioned ones, it is violating this rule.

15
E.F. Codd’s 12 Rules for RDBMS
• Rule 6 − Rule of Updating Views
Views should reflect the updates of their
respective base tables and vice versa. A view is a
logical table which shows restricted data. Views
generally make the data readable but not
modifiable. Views help in data abstraction.

16
• Rule 7 − Rule of Set level insertion, update
and deletion
A single operation should be sufficient to
retrieve, insert, update and delete the data.
• Rule 8 − Rule of Physical Data
Independence
Batch and end user operations are logically
separated from physical storage and respective
access methods.

17
E.F. Codd’s 12 Rules for RDBMS
• Rule 9 − Rule of Logical Data Independence
Batch and end users can change the database schema without
having to recreate it or recreate the applications built upon it.
• Rule 10 − Rule of Integrity Independence
Integrity constraints should be available and stored as metadata
in data dictionary and not in the application programs.
• Rule 11 − Rule of Distribution Independence
The Data Manipulation Language of the relational system should
not be concerned about the physical data storage and no
alterations should be required if the physical data is centralized or
distributed.
• Rule 12 − Rule of Non Subversion
Any row should obey the security and integrity constraints
imposed. No special privileges are applicable.

18
SQL Server
ANSI SQL MS Access IBM DB2 MySQL Oracle 10
2000

Character char char char char char

Character
varchar varchar varchar varchar varchar
Varying
number
Integer (long int int int int
integer)
number
SmallInt smallint smallint smallint smallint
(Integer)

number
Real real real real real
(Double)

number
Decimal decimal decimal decimal decimal
(Decimal)

Date Date datetime date date date

Time Time datetime time time time

19
SQL (STRUCTURED QUERY LANGUAGE)
• SQL is Structured Query Language, which is a
computer language for storing, manipulating
and retrieving data stored in a relational
database.
• SQL is the standard language for Relational
Database System. All the Relational Database
Management Systems (RDMS) like MySQL,
MS Access, Oracle, Sybase, Informix, Postgre
and SQL Server use SQL as their standard
database language.
20
Applications of SQL
• Allows users to access data in the relational
database management systems.
• Allows users to describe the data.
• Allows users to define the data in a database and
manipulate that data.
• Allows users to create and drop databases and
tables.
• Allows users to create view, stored procedure,
functions in a database.
• Allows users to set permissions on tables,
procedures and views.

21
SQL Commands
• 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
• DCL-Data Control Language

22
23
• 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:
– SELECT [DISTINCT] Attribute List FROM R1,R2….RM
– [WHERE condition]
– [GROUP BY (Attributes)[HAVING condition]]
– [ORDER BY(Attributes)[DESC]];
24
DDL, DML, DCL, and the database
development process

25
• Data Definition Language is used to define the
database structure or schema.
• DDL is also used to specify additional
properties of the data.
• The storage structure and access methods
used by the database system by a set of
statements in a special type of DDL called a
data storage and definition language.
• These statements define the implementation
details of the database schema, which are
usually hidden from the users.
26
DDL COMMANDS
Sr.No. Command & Description

CREATE
Creates a new table, a view of a table, or other object in the
1
database.

ALTER
2
Modifies an existing database object, such as a table.
DROP
3 Deletes an entire table, a view of a table or other objects in the
database.
TRUNCATE
4 removes all rows from a table, but the table structure and its columns,
constraints, indexes, and so on remain.
RENAME
5
Set a new name for any existing table
27
General syntax for CREATE TABLE
statement used in data definition language

28
CREATE TABLE
CREATE TABLE base-table-name (colname
datatype [column constraints – NULL/NOT
NULL, DEFAULT…, UNIQUE, CHECK…,
PRIMARY KEY],
[,colname datetype [column constraints …]]
...
[table constraints – PRIMARY KEY…, FOREIGN
KEY…, UNIQUE…, CHECK…]

29
Datatypes

30
Creating the Tables for the University
Database
CREATE TABLE Student (
stuId CHAR(6),
lastName CHAR(20) NOT NULL,
firstName CHAR(20) NOT NULL,
major CHAR(10),
credits SMALLINT DEFAULT 0,
CONSTRAINT Student_stuId_pk PRIMARY KEY (stuId),
CONSTRAINT Student_credits_cc CHECK (credits>=0 AND
credits <150));
CREATE TABLE Faculty (
facId CHAR(6),
name CHAR(20) NOT NULL,
department CHAR(20) NOT NULL,
rank CHAR(10),
CONSTRAINT Faculty_facId_pk PRIMARY KEY (facId));

31
ALTER TABLE Command
• To add a new column
ALTER TABLE basetablename ADD columnname datatype;

Ex. ALTER TABLE Student ADD COLUMN birthdate DATETYPE;


– Cannot specify NOT NULL, since existing records have no
value for this field

• To drop a column
ALTER TABLE basetablename DROP COLUMN columnname;

Ex. ALTER TABLE Student DROP COLUMN major;

32
Other Changes to Tables
• Renaming a table:
RENAME TABLE old-table-name TO new-table-name;

Ex: RENAME TABLE FACULTY TO TEACHERS;

• Dropping a table:
– CASCADE; //remove table and all references to it (ex. in
a REFERENCES)
– RESTRICT; //remove the table only if there are no
references to it elsewhere

DROP TABLE basetablename;


Ex. DROP TABLE CLASS;

33
• Truncating a table:
TRUNCATE TABLE removes all rows from a
table, but the table structure and its columns,
constraints, indexes, and so on remain.
Syntax
Truncate table table_name;

34

You might also like