RDBMS - SQL
RDBMS - SQL
DEPARTMENT
DEPTNO DNAME LOCATION
10 HR NEW YORK
20 ACCOUNTS BRAZIL
30 SALES CANADA
40 IT INDIA
COMPONENT OF A TABLE
Byte : group of 8 bits and is used to store a
character.
Data Item : smallest unit of named data. It
represent one type of information
and often referred to as a field or
column information
Record : collection of data items which
represent a complete unit of
information
Table : collection of all Rows and Columns.
Table
Fields
1) Degree of Table
2) Cardinality of Table
3) Attributes of Table
4) Tuple
5) Data types of Book Code and Price (as studied in Python)
CONCEPT OF KEYS
EMPNO ENAME GENDER DEPTNO SALARY COMM
1 ANKITA F 10 20000 1200
2 SUJEET M 20 24000
3 VIJAYA F 10 28000 2000
4 NITIN M 30 18000 3000
5 VIKRAM M 30 22000 1700
DEPARTMENT
Parent
DEPTNO DNAME LOCATION
Table
10 HR NEW YORK
20 ACCOUNTS BRAZIL
30 SALES CANADA
40 IT INDIA
From the Above table definition we can observe that the
DEPTNO column of EMPLOYEE table is deriving its value
from DEPTNO of table DEPARTMENT. So we can say that the
DEPTNO of EMPLOYEE table is a foreign key whose value is
dependent upon the Primary key column DEPTNO of table
DEPARTMENT.
REFERENTIAL INTEGRITY
Used to ensure relationship between records in
related tables are valid and user don’t
accidentally delete or change the related data.
Referential integrity can be applied when:
The master table’s column is a Primary Key or has a
unique index
The related fields have the same data type
Both tables must belong to same database.
REFERENTIAL INTEGRITY
When referential integrity is enforced using
Foreign Key you must observe the following
rules:
You cannot enter a value in Child Table which is not
available in Master Table’s Primary key column.
However you can enter NULL values in foreign key
You cannot delete a record from Master Table if
matching record exists in related table
You cannot modify or change the Primary Key value
in Master table if its matching record is present in
related table.
BRIEF HISTORY OF MYSQL
MySQL is freely available open source RDBMS
Can be downloaded from www.mysql.org
In MySQL information is stored in Tables.
Provides features that support secure environment
for storing, maintaining and accessing data.
It is fast, reliable, scalable alternative to many of the
commercial RDBMS today.
Create and supported by MySQL AB, a company
based in Sweden. This company is now subsidiary of
Sun Microsystems. On April 2009 Oracle Corp.
acquires Sun Microsystems.
The chief inventor of MySQL was Michael
Widenius(a.k.a Monty). MySQL has been named after
Monty’s daughter My. The logo of MySQL is dolphin
and name of that dolphin is ‘Sakila’
MYSQL DATABASE SYSTEM
MySQL database system refers to the
combination of a MySQL server instance and
MySQL database.
It operates using Client/Server architecture in
which the server runs on the machine containing
the database and client connects to server over a
network
MySQL is a multiuser database system, meaning
several users can access the database
simultaneously
MYSQL DATABASE SYSTEM
The Server
Listens for client requests coming in over the
network and access the database as per the
requirements and provide the requested information
to the Client
The Client
Are the programs that connect to MySQL server and
sends requests to the server and receives the
response of Server. Client may be the MySQL prompt
or it may be Front-end programming which connect
to server programmatically like connecting to MySQL
using Python Language or Java or any other
language
FEATURES OF MYSQL
Speed
MySQL runs very fast.
Ease of Use
Can be managed from command line or GUI
Cost
Is available free of cost. It is Open Source
Query language Support
Supports SQL
Portability
Can be run on any platform and supported by various
compilers
Data Types
Supports various data types like Numbers, Char etc.
FEATURES OF MYSQL
Security
Offers privileges and password systems that is very flexible
and secure.
Scalability and Limits
Can handle large databases. Some of real life MySQL
databases contains millions of records.
Connectivity
Clients can connect to MySQL using drivers
Localization
The server can provide error message to client in many
language
Client and Tools
Provides several client and utility programs. Like
mysqldump and mysqladmin. GUI tools like MySQL
Administration and Query Browser
Enter the
password
given
STARTING MYSQL during
installation
VINOD
Click on Start All Programs MySQL
MySQL Server MySQL Command Line Client
mysql> prompt
means now MySQL
is ready to take your
command and
execute
Embedded DML
View
Authorization
Integrity
Transaction Control
DATA DEFINITION LANGUAGE
It allows to create database objects like creating
a table, view or any other database objects.
The information about created objects are stored
in special file called DATA DICTIONARY
DATA DICTIONARY contains metadata i.e. data
about data.
While creating a table DDL allows to specify –
name of table, attributes, data types of each
attribute, may define range of values that
attributes can store, etc
Major commands of DDL are – CREATE,
ALTER, DROP
DATA MANIPULATION LANGUAGE
It allows to perform following operation on
table
Retrieval of information stored in table
Insertion of new data in table
Modification of existing data in table
Deletion of existing data from table
DML is of 2 type
Procedural DML (in this we specify what data is
needed and how to get it)
Non-Procedural DML (in this we specify what
data is needed without specifying how to get it)
Main DML commands are – SELECT,
INSERT, UPDATE AND DELETE
JUST A MINUTE…
What is Database? What are the advantages of
Database System?
What is DDL and DML? Give examples of
command belonging to each category
What is the difference between Primary key and
Candidate key
What is Primary Key? What are the restriction
imposed by Primary Key? How many primary
key can be applied on a Table?
What is Degree and Cardinality of table?