0% found this document useful (0 votes)
41 views7 pages

Unit 1 Database Concepts RDBMS Tool

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

Unit -I Database Concepts -RDBMS Tool

Grade- XII

Database Management Software (DBMS) simplifies the task of managing the data
and extracting useful information out of it.

Basic Concepts and Definitions


Data is a collection of raw facts which have not been processed to reveal useful
information. Information is produced by processing data

A database has the following properties:


1) A database is a representation of some aspect of the real world also
called miniworld. Whenever there are changes in this mini world they are
also reflected in the database.
2) It is designed, built and populated with data for specific purpose.
3) It can be of any size and complexity.
4) It can be maintained manually or it may be computerized

Need for a Database


Data is stored in the form of files. A number of application programs are written by
programmers to insert, delete, modify and retrieve data from these files. New
application programs will be added to the system as the need arises.

The various operations that need to be performed on a database are as follows:


1. Defining the Database: It involves specifying the data type of data that will
be stored in the database and also any constraints on that data.
2. Populating the Database: It involves storing the data on some storage medium
that is controlled by DBMS.
3. Manipulating the Database: It involves modifying the database, retrieving data
or querying the database, generating reports from the database etc.
4. Sharing the Database: Allow multiple users to access the database at the same time.
5. Protecting the Database: It enables protection of the database
from software/ hardware failures and unauthorized access.
6. Maintaining the Database: It is easy to adapt to the changing requirements.
Characteristics of Database Management Systems

The main characteristics of a DBMS are as follows:


1. Self-describing Nature of a Database System: DBMS contains not
only the database but also the description of the data that it stores. This
description of data is called metadata.
Meta-data is stored in a database catalogue or data dictionary. It
contains the structure of the data and also the constraints that are
imposed on the data.

2. Insulation Between Programs and Data: Since the definition of data is


stored separately in a DBMS, any change in the structure of data would be
done in the catalogue and hence programs which access this data need not
be modified. This property is called Program-Data Independence.
3. Sharing of Data: A multiuser environment allows multiple users to access
the database simultaneously. Thus a DBMS must include concurrency control
software to allow simultaneous access of data in the database without any
inconsistency problems.
Types of Users of DBMS
DBMS is used by many types of users depending on their requirements and
interaction with the DBMS. There are mainly four types of users:
1. End Users: Users who use the database for querying, modifying and generating
reports as per their needs. They are not concerned about the working and designing
of the database. They simply use the DBMS to get their task done.
2. Database Administrator (DBA): As the name implies, the DBA administers
the database and the DBMS. The DBA is responsible for authoring access,
monitoring its use, providing technical support, acquiring software and hardware
resources.
3. Application Programmers: Application programmes write application programs
to interact with the database. These programs are written in high level languages and
SQL to interact with the database.
4. System Analyst: System analyst determines the requirements of the end users and
then develops specifications to meet these requirements. A system analyst plays a
major role in the database design and all the technical, economic and feasibility
aspects.

Advantages of using DBMS Approach


The need of DBMS itself explains the advantages of using a DBMS.
Following are the advantages of using a DBMS:
1. Reduction in Redundancy: Data in a DBMS is more concise because
of the central repository of data. All the data is stored at one place. There
is no repetition of the same data. This also reduces the cost of storing data
on hard disks or other memory devices.
2. Improved Consistency: The chances of data inconsistencies in a
database are also reduced as there is a single copy of data that is accessed
or updated by all the users.
3. Improved Availability: Same information is made available to different
users. This helps sharing of information by various users of the database.
4. Improved Security: Though there is improvement in the availability of
information to users, it may also be required to restrict the access to
confidential information. By making use of passwords and controlling users'
database access rights, the DBA can provide security to the database.
5. User Friendly: Using a DBMS, it becomes very easy to access, modify and delete data.
It reduces the dependency of users on computer specialists to perform
various data related operations in a DBMS because of its user friendly
interface.
Limitations of using DBMS Approach
The two main disadvantages of using a DBMS:
1. High Cost: The cost of implementing a DBMS system is very high. It is
also a very time consuming process which involves analyzing user
requirements, designing the database specifications, writing application
programs and then also providing training.
2. Security and Recovery Overheads: Unauthorized access to a database can lead
to threat to the individual or organization depending on the data stored. Also the data
must be regularly backed up to prevent its loss due to fire, earthquakes, etc.
In relational model,
A row is called a Tuple.
A column is called an
Attribute. A table is called
as a Relation.
The data type of values in each column is called the Domain.
The number of attributes in a relation is called the Degree of
a relation. The number of rows in a relation is called the
Cardinality of a relation.
Relation Schema R is denoted by R (A , A , A …, A ) where R is the relation name 1
2 3, n and A , A , A ,….A is the list of attributes.
Key is the minimal superkey, which means it is that superkey of a relation
from which if any attribute is removed then it no longer remains a
superkey.
Candidate key: A column or a group of columns which can be used as the
primary key of a relation is called a Candidate key because it is one of the
candidates available to be the primary key of the relation.
Primary Key:The group of one or more columns used to uniquely identify each row
of a relation is called its Primary Key.

Relational Model Constraints

Constraints, are restrictions on the values, stored in a database based on the


requirements. For example, in the relation EMPLOYEE, the Employee_ID
must be a 4-digit number, the Date_of_Birth must be such that the birth year
> 1985.
We describe below various types of constraints in Relational model:
1. Domain Constraint: It specifies that the value of every attribute in each
tuple must be from the domain of that attribute. For example, the
Employee_ID must be a 4-digit number. Hence a value such as “12321” or
“A234” violates the domain constraint as the former is not 4-digit long and
the letter contains an alphabet.
2. Key Constraint: Before we can explain this constraint, we need to
describe the terms superkey, key, candidate key and primary key.
3. Null Value Constraint: Sometimes it is required that certain attributes
cannot have null values. For example, if every EMPLOYEE must have a valid
name then the Name attribute is constrained to be NOT NULL.
4. Entity Integrity Constraint: This constraint specifies that primary key
of a relation cannot have null value. The reason behind this constraint is
that we know primary key contains no duplicates.

Self-Referencing Tables: A foreign key constraint can reference


columns within the same table. These tables are called as self-
referencing tables.
Naming of Constraint: A constraint can be named by using the keyword
CONSTRAINT followed by the name of the constraint and its specification.
CREATE TABLE Teacher ( Teacher_ID INTEGER, First_Name VARCHAR(20)
NOT NULL, Last_Name VARCHAR(20), Gender CHAR(1), Salary
DECIMAL(10,2) DEFAULT 40000, Date_of_Birth DATE, Dept_No INTEGER,
CONSTRAINT TEACHER_PK PRIMARY KEY (Teacher_ID), CONSTRAINT
TEACHER_FK FOREIGN KEY (Dept_No) REFERENCES
Department(Dept_ID) ON DELETE SET NULL ON UPDATE SET NULL );

Drop Table Command: This command is used to delete tables. For


example, suppose you want to drop the Teacher table then the command
would be:

Types of SQL Commands


MySQL follows SQL specifications for its commands. These SQL commands can be
categorized as (DDL, DML)–
Data Definition Language (DDL): These SQL commands are used to create,
alter and delete database objects like table, views, index etc.
Example : CREATE , ALTER , DROP etc.
Data Manipulation Language (DML): These commands are used to insert,
delete, update and retrieve the stored records from the table.
Ex. SELECT…., INSERT…, DELETE…, UPDATE…. etc.
Alter Table Command: This command is used to modify the base table
definition. The modifications that can be done using this command are:
Adding a column: Suppose we want to add a column Age in the
Teacher table. Following command is used to add the column:
ALTER TABLE Teacher ADD Age INTEGER;
Dropping a column: A column can be dropped using this command but one must
specify the options (RESTRICT or CASCADE) for the drop behavior. As discussed
earlier, RESTRICT would not let the column be dropped if it is being referenced in
other tables and CASCADE would drop the constraint associated with this column in
this relation as well as all the constraints that refer this column.
ALTER TABLE Teacher DROP Dept_No CASCADE;
Altering a Column: A column definition can also be altered. For example –
dropping the default value or defining a new default value. For example, in the
Teacher table the default value of Salary is 40000. If you want to drop this default
value or change this value to 30000 then it can be done byusing the following
commands:
ALTER TABLE Teacher ALTER Salary DROP
DEFAULT; ALTER TABLE Teacher ALTER Salary
SET DEFAULT 30000;
Dropping keys: A foreign key/primary key/key can be dropped by using ALTER
TABLE command. For example if you want to delete the foreign key
TEACHER_FK in the Teacher table then following command can be used:
ALTER TABLE Teacher DROP FOREIGN KEY TEACHER_FK;

Insert Command: This command is used to insert a tuple in a relation. We must


specify the name of the relation in which tuple is to be inserted and the values. The
values must be in the same order as specified during the Create Table command.
INSERT INTO Teacher VALUES (101,"Shanaya", "Batra", 'F', 50000, '1984-08-11', 1);

Update Command: This command is used to update the attribute values of one or
more tuples in a table. For example in the Teacher table, we want to update the
Salary of teacher with Teacher_ID=101 to 55000. This can be done using the
following command:
UPDATE Teacher SET Salary=55000 WHERE Teacher_ID=101;

Delete Command: In order to delete one or more tuples, DELETE command is


used. If we want to delete the tuple for Teacher with ID=101 the command would be:
DELETE FROM Teacher WHERE Teacher_ID=101;

Select Command: The SELECT Command is used to retrieve information from a


database. There are various ways in which the SELECT command can be used.
Syntax of SELECT Command is as follows:
SELECT <attribute list> FROM <table list> WHERE <condition>

You might also like