Database Management System
Database Management System
OMANDHUR, TINDIVANAM.
CLASS 10
DATABASE MANAGEMENT SYSTEM NOTES
SESSION 1
Definition of Data & Database:
Data is nothing but collection of facts. Singular form of data is datum. When the data is
processed, data is transformed into information.
A database is an organized collection of data. A database contains information about one
particular enterprise. It maintains any information that may be necessary to the decision-making
processed involved in the management of that organization.
Database Management System:
A database management system is a software package with computer programs that controls the
creation, maintenance, and use of a database. It allows organizations to conveniently develop
databases for various applications. A database is an integrated collection of data records, files,
and other objects. A DBMS allows different user application programs to concurrently access the
same database.
Well known DBMSs include Oracle, IBM DB2, Microsoft SQL Server, Microsoft Access,
PostgreSQL, MySQL, FoxPro, and SQLite.
Types of DBMS:
Data can be organized into two types:
• Flat File: Data is stored in a single table. Usually suitable for less amount of data.
• Relational: Data is stored in multiple tables and the tables are linked using a common field.
Relational is suitable for medium to large amount of data.
Database servers:
Database servers are dedicated computers that hold the actual databases and run only the DBMS
and related software.
Advantages of Database:
Reduces Data Redundancy: no chance of encountering duplicate data
Sharing of Data: The users of the database can share the data among themselves.
Data Integrity: Data integrity means that the data is accurate and consistent in the database.
Data Security: Only authorized users are allowed to access the database and their identity is
authenticated using a username and password.
Privacy: The privacy rule in a database states that only the authorized users can access a
database according to its privacy constraints.
Backup and Recovery: Database Management System automatically takes care of backup and
recovery.
Data Consistency: Data Consistency means there should be multiple mismatching copies of the
same data.
Confidentiality: DBMS software ensures different views for the different users which makes the
data confidential. It is highly securable also by assigning a lock to it by using keys.
DATA MODELS
A database can be designed in different ways depending on the data being stored. This structure
of database is knows as data model that describes the manner in which data will be stored and
retrieved.
A data model consists of components for describing on the data, relationships among them and
the constraints that hold data. There are different data models such as hierarchical data model,
network data model and relational data model.
HIERARCHICAL DATA MODEL
In this model the data is organized into a tree like structure. The data is stored in the form of
records. A record is a collection of fields and its data values. All these records are linked to each
other at various levels thereby forming a hierarchy.
NETWORK DATA MODEL
In this model, multiple records are linked to same master file. It is also considered as an inverted
tree where master is present in the bottom of the tree and the branches contain information linked
to the master.
RELATIONAL DATA MODEL
This data model is based on the principle of setting relationships between two or more tables of
the same data base.
DATABASE OBJECTS (Field, Record and Table);
Tables:
A table is a set of data elements (values) that is organized using a model of vertical columns
(which are identified by their name) and horizontal rows.
Columns or Fields or Attributes:
A column is a set of data values of a particular simple type, one for each row of the table.
Rows or Records or Tuples:
A row also called a Record or Tuple represents a single, data item in a table.
Fields
SESSION 6
UNDERSTAND AND USE SQL AND DDL COMMANDS
SQL (Structured Query Language) commands are grouped into four major
categories depending on their functionality
1. DATA DEFINITION LANGUAGE(DDL): These commands enable to perform the
following tasks
CREATE
ALTER
DROP
ADD COMMENTS
2. TRANSACTION CONTROL LANGUAGE (TCL): These commands manage changes
made by DML commands. These are used for managing changes affecting the data.
COMMIT
ROLLBACK
SAVEPOINT
3. DATA CONTROL LANGUAGE: It is used to create roles, permissions and referential
Integrity. These commands are used for providing security to database objects. These
commands are GRANT and REVOKE
4. DATA MANIPULATION LANGUAGE: These SQL commands are used for storing,
retrieving, modifying and deleting data. These commands are SELECT,
INSERT,UPDATE AND DELETE
CREATE DATABASE:
SYNTAX:
CREATE DATABASE <DB_NAME>
Example:
CREATE DATABASE Test;
CREATE TABLE:
SYNTAX:
CREATE TABLE <TABLE_NAME>
(
Column_name1 datatype1,
Column_name2 datatype2,
Column_name3 datatype3,
Column_name4 datatype4);
Example:
CREATE TABLE Student(
Studentid int,
Name varchar(100),
Age int);
ALTER TABLE:
The Alter command is used for altering the table structure, such as
To add a column to existing table
To rename any existing column
To change datatype of any column or to modify its size
To drop a column from the table
To add a column to existing table
SYNTAX:
ALTER TABLE table_name ADD(
Column_name datatype):
Example:
ALTER TABLE student ADD (
Address varchar(200)
);
SYNTAX:
ALTER TABLE table_name DROP (column_name);
Example:
ALTER TABLE Student DROP(address);
DROP COMMAND
SYNTAX:
DROP TABLE table_name
Example:
DROP TABLE Student;
INSERTING VALUES
SYNTAX:
INSERT INTO <tablename>
Values ()
Example:
INSERT INTO employee(ecode,ename,sex)
VALUES (1001,’Amit’,’M’)
UPDATING VALUES
SYNTAX:
UPDATE <tablename>
SET value
Example
UPDATE employee
SET ROLL =250 where icode =101
DISPALYING VALUES
SYNTAX
SELECT * FROM <TABLENAME) WHERE <CONDITION>
Example:
Select * from garment where size =’XL’ (* indicates displaying all the fields in the table)