What is database ?
• A database is a collection of information that is
organized so that it can easily be accessed,
managed, and updated.
• A databases can be classified
according to types of content:
bibliographic, full-text, numeric, and
images
What is Database Management System
The process of managing data as a resource
that is valuable to an organization or
business.
It is the process of developing data
architectures, practices and procedures
dealing with data and then executing these
aspects on a regular basis.
Database management systems
Set of computer programs that
controls the creation, maintenance,
and the use of the database of an
organization and its end users.
Database management systems
It allows organizations to place
control of organization wide
database development in the hands
of Database Administrators (DBAs)
and other specialist.
Database management systems
DBMSes may use any of a variety of
database models, such as the
network model or relational model.
In large systems, a DBMS allows
users and other software to store
and retrieve data in a structured
way.
Data Model
Used to organize data.
Ensure that the data is of good quality for the
users
(cardinality and referential integrity rules ).
Three uses getting data in, integrating data
and getting data out.
Conceptual Data Model
A conceptual data model identifies the highest-
level relationships between the different entities.
Features of conceptual data model include:
Includes the important entities and the
relationships among them.
No attribute is specified.
No primary key is specified.
The figure below is an example of a conceptual
data model.
Conceptual Data Model
The conceptual model is concerned with the real world view
and understanding of data
Logical Model Design
the logical model is a generalized formal structure in the
rules of information science
Physical Model Design
The physical model specifies how this will be executed in a
particular DBMS instance
Data Independence
The ability to use the data without knowing
its representation detail is called data
independence.
Data Independence
Applications insulated from how data is
structured and stored.
Physical data independence:
Protection from changes in physical structure
of data.
Logical data independence:
Protection from changes in logical structure
of data.
Schema
In a relational database, the schema defines the
tables, the fields, relationships, views, indexes,
packages, procedures, functions, queues, triggers,
types, sequences, views, synonyms, database links,
directories and other elements.
SQL
SQL uses a collection of imperative verbs
whose effect is to modify the schema of the
database by adding, changing, or deleting
definitions of tables or other objects.
These statements can be freely mixed with
other SQL statements, so the DDL is not truly
a separate language. The most commonly
encountered statement is CREATE TABLE.
Data Definition Language (DDL)
CREATE statements
DROP statements
ALTER statements
CREATE statement
A CREATE statement in SQL creates an
object inside of a relational database
management system (RDBMS).
The types of objects that can be created
depends on which RDBMS is being used, but
most support the creation of tables, indexes,
users, synonyms and databases.
Column Definitions: A comma-separated
CREATE [TEMPORARY] TABLE [table name] ( [column definitions] ) [table parameters].
list consisting of any of the following
Column definition: [column name] [data type]
{NULL | NOT NULL} {column options}
Primary key definition: PRIMARY KEY
( [comma separated column list] )
CONSTRAINTS: {CONSTRAINT} [constraint
definition]
RDBMS specific functionality
CREATE TABLE employees
( Emp_id INTEGER PRIMARY
KEY, first_name CHAR(50)
NULL, last_name CHAR(75)
NOT NULL, dateofbirth DATE
NULL );
DROP statements
To destroy an existing database, table, index,
or view.
DROP objecttype objectname.
DROP TABLE employees;
The DROP statement is distinct from the
DELETE and TRUNCATE statements, in that
they do not remove the table itself.
ALTER statements
To modify an existing database object
ALTER objecttype objectname parameters.
ALTER TABLE sink ADD bubbles INTEGER;
ALTER TABLE sink DROP COLUMN bubbles;
Data Manipulation Language (DML)
Data Manipulation Language (DML) is a
family of computer languages used by
computer programs and/or database users to
insert, delete andd update data in a database.
SELECT ... FROM ... WHERE ...
INSERT INTO ... VALUES ...
UPDATE ... SET ... WHERE ...
DELETE FROM ... WHERE ...
Data Control Language
A Data Control Language (DCL) is a
computer language and a subset of SQL, used
to control access to data in a database.
Examples :
GRANT to allow specified users to perform
specified tasks.
REVOKE to cancel previously granted or
denied permissions.