RELATIONAL DATABASE
MANAGEMENT SYSTEM
(RDBMS)
BY MIAN A. SHABBIR
DATABASE MANAGEMENT SYSTEM
• Database Management System – is a system software that allows users to specify
the structure of a database with a systematic way to create, query and update data
in the database. For Example: Limiting of access to database for specific users.
• The database management system essentially serves as an interface between the
database and end users or application programs, ensuring that data is consistently
organized and remains easily accessible.
• The DBMS manages three important things: the data, the database engine that
allows data to be accessed, locked and modified -- and the database schema, which
defines the database’s logical structure.
DATA, SCHEMA, AND DATABASE
• Data – is numerical, character or other symbols which can be recorded in a form for
processing by a computer. For Example: Names and Addresses of employees in a
company.
• Schema – The schema is the structure of data, whereas the data are the facts.
Schema basically indicates the rules which the data must obey. Such rules can be
enforced by a database. For Example: Age limit of employees being hired in a
company is between 18 – 90 years old.
• Database – A database is a collection of related data arranged for searching quickly
and efficiently.
WHAT IS RDBMS?
• RDBMS is a database management system based on relational model defined by
E.F.Codd.
• Data is stored in the form of rows and columns. The relations among tables are also
stored in the form of the table.
• RDBMS use the language known as SQL (Sequel)
• SQL is a simple programming language used for accessing and managing data in
relational databases.
• Shares a common column in two or more tables (Primary Key and Foreign Key)
FEATURES OF RDBMS
• Provides data to be stored in tables
• Persists data in the form of rows and columns
• Provides primary key to uniquely identify the rows in a table
• Provides a (view) virtual table creation in which sensitive data can be stored
• Provides multi user accessibility that can be controlled by individual users
• And it features four types of relationships in database
RELATIONSHIPS IN DATABASE
• One to One – One entity is associated with another entity. For Example: Each
employee belong to one department.
• One to Many – One entity is associated with many other entities. For Example: A
company is associated with all working employees in one branch/office/country.
• Many to One – Many entities are associated with only one entity. For Example:
Many employees have one manager.
• Many to Many – Many entities are associated with many other entities. For
Example: Many employees associated with multiple assignments and multiple
assignments are associated with multiple employees at the same time.
RULES OF RDBMS
• These rules are strictly implemented as part of the overall database design:
1. Each table has a unique name
2. Each table contains multiple rows
3. Each row in a table is unique
4. Every table has a key to uniquely identify rows
5. Each column in a table has a unique attribute name
ELEMENTS OF RDBMS
• There are four main database elements in a relational database:
• Tables – Data collection objects also known as relation.
• Tuple – Row of a relation which represents an instance of a relation
• Attribute – named column of a relation
• Queries – Inquiry about the stored data.
• Forms – A predefined format to display or enter data
• Reports – Printable version of database information
SQL COMMANDS
• There are various categories of sql commands that are used to handle the data.
1. Data Definition Language (DDL) commands, are used to create, and modify
database objects. For Example: CREATE, ALTER, DROP
2. Data Manipulation Language (DML) commands are used to manipulate data. For
Example: DELETE, INSERT, SELECT, UPDATE
3. Data Control Language (DCL) commands are used to control privileges in
database. For Example: GRANT, REVOKE
SQL CONSTRAINTS
• Constraints are the rules enforced on data columns on table.
• These are used to limit the type of data that can go into a table.
• This ensures the accuracy and reliability of the data in the database.
• Constraints could be column level or table level.
• Column level constraints are applied only to one column where as table level
constraints are applied to the whole table.
COMMON SQL CONSTRAINTS
• NOT NULL Constraint: Ensures that a column cannot have NULL value.
• DEFAULT Constraint: Provides a default value for a column when none is specified.
• UNIQUE Constraint: Ensures that all values in a column are different.
• PRIMARY Key: Uniquely identified each rows/records in a database table.
• FOREIGN Key: Uniquely identified a rows/records in any another database table.
• CHECK Constraint: The CHECK constraint ensures that all values in a column
satisfy certain conditions.
• INDEX: Use to create and retrieve data from the database very quickly.
DATA DEFINITION LANGUAGE SCRIPT
CREATE TABLE EMP (
EMPNO NUMBER(4) PRIMARY KEY,
ENAME VARCHAR2(15) NOT NULL,
JOB VARCHAR2(10),
MGR NUMBER(5),
HIREDATE DATE DEFAULT (SYSDATE),
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(4)) ;
DATA MANIPULATION LANGUAGE SCRIPT
INSERT INTO EMP VALUES (7782, 'CLARK' , 'MANAGER' , 7839 , '09-JUN-81' , 2450 ,
NULL , 10);
INSERT INTO EMP VALUES (7788, 'SCOTT' , 'ANALYST' , 7566 , '19-APR-87' , 3000 ,
NULL , 20);
INSERT INTO EMP VALUES (7839, 'KING' , 'PRESIDENT' , NULL , '17-NOV-81' , 5000 ,
0, 10);
INSERT INTO EMP VALUES (7844, 'TURNER' , 'SALESMAN' , 7698 , '08-SEP-81' , 1500
, 0 , 30);
INSERT INTO EMP VALUES (7876, 'ADAMS' , 'CLERK' , 7788 , '23-MAY-87' , 1100 ,
NULL , 20);
INSERT INTO EMP VALUES (7900, 'JAMES' , 'CLERK' , 7698 , '03-DEC-81' , 950 , NULL
DATA CONTROL LANGUAGE SCRIPT
• GRANT SELECT
ON employee
TO CLARK;
• GRANT UPDATE, DELETE
ON employee
TO CLARK;
• REVOKE SELECT
ON employee
FROM CLARK;
• REVOKE UPDATE, DELETE
ON employee
FROM CLARK;
PRIMARY KEY, FOREIGN KEY
Primary Key
• Primary Key is used for unique identification of each row in a table. The rule for
primary key is that values have to be unique and not null.
Foreign Key
• Foreign Key identifies a column with primary key column of another table for
storing data. The values of foreign key are exactly same as the values of primary
keys of other tables.
EXAMPLE OF PRIMARY AND FOREIGN KEY
Patient Id Name D.o.B Gender Phone Doctor Id
125 Clark 04-05-1979 Male 123-456-7890 10
149 Dave 06-21-1984 Male 444-555-6666 20
160 Lisa 11-13-1991 Female 777-888-9999 10
199 Joe 07-02-1993 Male 111-222-0000 10
Doctor Id Doctor Room
10 Dr. Wilson 08
20 Dr. Frank 02
Primary Key
Foreign Key
DBMS VS RDBMS
DBMS
• Introduced in 1960s
• Followed navigational modes for data
storage
• Data fetching is slower for large
amount of data
• Data redundancy is common in this
model leading to difficulty in
maintaining data
• Examples are dBase, Microsoft Access,
LibreOffice Base, FoxPro
RDBMS
• Introduced in 1970s
• Uses relationship between tables using
primary keys, foreign keys and indexes
• Data fetching is faster because of its
relational model
• Keys and indexes are used in the tables
to avoid redundancy
• Example are SQL Server, Oracle,
MySQL, MariaDB, SQLite
RDBMS NORMALIZATION
• Database normalization or simply normalization, is the process of organizing the
data in a database
• There are two main goal of normalization process:
1. Eliminating redundant data
2. Ensuring of data dependence
• Both of these goals reduce the amount of space a database consumes and ensure
that data is logically stored
BENEFITS OF NORMALIZING
• By doing normalization the process of searching and creating tables is faster
• More needed tables can be derived for clear vision
• Less redundant data and fewer null values will make the database more compact
• The indexes of tables make data modification commands execution much faster
• Normalization facilitates in reducing data modification anomalies
SQL JOINS
• SQL join is a instruction to a database to combine data from more than one table.
• There are different type of joins, which have different rules for the results they
create.
• Types of Joins:
1. Inner join
2. Left outer join
3. Right outer join
4. Full outer join
5. Cross join
6. Self join
INNER JOIN
• The INNER JOIN or EQUI JOIN creates a new result table by combining column
values of two tables (table1 and table2) based upon the join-predicate.
• The query compares each row of table1 with each row of table2 to find all pairs of
rows which satisfy the join-predicate.
• INNER JOIN Script Syntax:
SELECT table1.column1, table2.column2
FROM table1
INNER JOIN table2
ON table1.common_field = table2.common_field;
LEFT OUTER JOIN
• A left outer join, or left join, results in a set where all of the rows from the first, or
left hand side, table are preserved. The rows from the second, or right hand side
table only show up if they have a match with the rows from the first table.
• LEFT OUTER JOIN Script Syntax:
SELECT table1.column, table2.column
FROM table1
LEFT OUTER JOIN table2
ON (table1.column = table2.column);
RIGHT OUTER JOIN
• A right outer join, or right join, is the same as a left join, except the roles are
reversed.
• All of the rows from the right hand side table show up in the result, but the rows from
the table on the left are only there if they match the table on the right.
• RIGHT OUTER JOIN Script Syntax:
SELECT column_name(s)
FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name=table2.column_name;
FULL OUTER JOIN
• A full outer join, or just outer join, produces a result set with all of the rows of both
tables, regardless of whether there are any matches.
• FULL OUTER JOIN Script Sytax:
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;
CROSS JOIN
• The CARTESIAN JOIN or CROSS JOIN returns the Cartesian product of the sets of
records from the two or more joined tables. The row count of the result is equal to
the number of rows in the first table times the number of rows in the second table.
• CROSS JOIN Script Syntax:
SELECT *
FROM table1
CROSS JOIN table2;
SELF JOIN
• Joining a table to itself is known as self join. In simple words, it means using a same
table twice.
• SELF JOIN Script Syntax:
SELECT a.column_name, b.column_name
FROM table1 a, table1 b
WHERE a.common_field = b.common_field;
REFERENCES
• http://docs.oracle.com/cd/E17952_01/index.html
• http://www.sql-join.com/
• http://www.mytecbits.com/microsoft/sql-server/what-is-dbms-what-is-rdbms
• http://www.tutorialspoint.com/sql/sql-rdbms-concepts.htm
• http://databases.about.com/od/specificproducts/a/normalization.htm

Relational Database Management System

  • 1.
  • 2.
    DATABASE MANAGEMENT SYSTEM •Database Management System – is a system software that allows users to specify the structure of a database with a systematic way to create, query and update data in the database. For Example: Limiting of access to database for specific users. • The database management system essentially serves as an interface between the database and end users or application programs, ensuring that data is consistently organized and remains easily accessible. • The DBMS manages three important things: the data, the database engine that allows data to be accessed, locked and modified -- and the database schema, which defines the database’s logical structure.
  • 3.
    DATA, SCHEMA, ANDDATABASE • Data – is numerical, character or other symbols which can be recorded in a form for processing by a computer. For Example: Names and Addresses of employees in a company. • Schema – The schema is the structure of data, whereas the data are the facts. Schema basically indicates the rules which the data must obey. Such rules can be enforced by a database. For Example: Age limit of employees being hired in a company is between 18 – 90 years old. • Database – A database is a collection of related data arranged for searching quickly and efficiently.
  • 4.
    WHAT IS RDBMS? •RDBMS is a database management system based on relational model defined by E.F.Codd. • Data is stored in the form of rows and columns. The relations among tables are also stored in the form of the table. • RDBMS use the language known as SQL (Sequel) • SQL is a simple programming language used for accessing and managing data in relational databases. • Shares a common column in two or more tables (Primary Key and Foreign Key)
  • 5.
    FEATURES OF RDBMS •Provides data to be stored in tables • Persists data in the form of rows and columns • Provides primary key to uniquely identify the rows in a table • Provides a (view) virtual table creation in which sensitive data can be stored • Provides multi user accessibility that can be controlled by individual users • And it features four types of relationships in database
  • 6.
    RELATIONSHIPS IN DATABASE •One to One – One entity is associated with another entity. For Example: Each employee belong to one department. • One to Many – One entity is associated with many other entities. For Example: A company is associated with all working employees in one branch/office/country. • Many to One – Many entities are associated with only one entity. For Example: Many employees have one manager. • Many to Many – Many entities are associated with many other entities. For Example: Many employees associated with multiple assignments and multiple assignments are associated with multiple employees at the same time.
  • 7.
    RULES OF RDBMS •These rules are strictly implemented as part of the overall database design: 1. Each table has a unique name 2. Each table contains multiple rows 3. Each row in a table is unique 4. Every table has a key to uniquely identify rows 5. Each column in a table has a unique attribute name
  • 8.
    ELEMENTS OF RDBMS •There are four main database elements in a relational database: • Tables – Data collection objects also known as relation. • Tuple – Row of a relation which represents an instance of a relation • Attribute – named column of a relation • Queries – Inquiry about the stored data. • Forms – A predefined format to display or enter data • Reports – Printable version of database information
  • 9.
    SQL COMMANDS • Thereare various categories of sql commands that are used to handle the data. 1. Data Definition Language (DDL) commands, are used to create, and modify database objects. For Example: CREATE, ALTER, DROP 2. Data Manipulation Language (DML) commands are used to manipulate data. For Example: DELETE, INSERT, SELECT, UPDATE 3. Data Control Language (DCL) commands are used to control privileges in database. For Example: GRANT, REVOKE
  • 10.
    SQL CONSTRAINTS • Constraintsare the rules enforced on data columns on table. • These are used to limit the type of data that can go into a table. • This ensures the accuracy and reliability of the data in the database. • Constraints could be column level or table level. • Column level constraints are applied only to one column where as table level constraints are applied to the whole table.
  • 11.
    COMMON SQL CONSTRAINTS •NOT NULL Constraint: Ensures that a column cannot have NULL value. • DEFAULT Constraint: Provides a default value for a column when none is specified. • UNIQUE Constraint: Ensures that all values in a column are different. • PRIMARY Key: Uniquely identified each rows/records in a database table. • FOREIGN Key: Uniquely identified a rows/records in any another database table. • CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy certain conditions. • INDEX: Use to create and retrieve data from the database very quickly.
  • 12.
    DATA DEFINITION LANGUAGESCRIPT CREATE TABLE EMP ( EMPNO NUMBER(4) PRIMARY KEY, ENAME VARCHAR2(15) NOT NULL, JOB VARCHAR2(10), MGR NUMBER(5), HIREDATE DATE DEFAULT (SYSDATE), SAL NUMBER(7,2), COMM NUMBER(7,2), DEPTNO NUMBER(4)) ;
  • 13.
    DATA MANIPULATION LANGUAGESCRIPT INSERT INTO EMP VALUES (7782, 'CLARK' , 'MANAGER' , 7839 , '09-JUN-81' , 2450 , NULL , 10); INSERT INTO EMP VALUES (7788, 'SCOTT' , 'ANALYST' , 7566 , '19-APR-87' , 3000 , NULL , 20); INSERT INTO EMP VALUES (7839, 'KING' , 'PRESIDENT' , NULL , '17-NOV-81' , 5000 , 0, 10); INSERT INTO EMP VALUES (7844, 'TURNER' , 'SALESMAN' , 7698 , '08-SEP-81' , 1500 , 0 , 30); INSERT INTO EMP VALUES (7876, 'ADAMS' , 'CLERK' , 7788 , '23-MAY-87' , 1100 , NULL , 20); INSERT INTO EMP VALUES (7900, 'JAMES' , 'CLERK' , 7698 , '03-DEC-81' , 950 , NULL
  • 14.
    DATA CONTROL LANGUAGESCRIPT • GRANT SELECT ON employee TO CLARK; • GRANT UPDATE, DELETE ON employee TO CLARK; • REVOKE SELECT ON employee FROM CLARK; • REVOKE UPDATE, DELETE ON employee FROM CLARK;
  • 15.
    PRIMARY KEY, FOREIGNKEY Primary Key • Primary Key is used for unique identification of each row in a table. The rule for primary key is that values have to be unique and not null. Foreign Key • Foreign Key identifies a column with primary key column of another table for storing data. The values of foreign key are exactly same as the values of primary keys of other tables.
  • 16.
    EXAMPLE OF PRIMARYAND FOREIGN KEY Patient Id Name D.o.B Gender Phone Doctor Id 125 Clark 04-05-1979 Male 123-456-7890 10 149 Dave 06-21-1984 Male 444-555-6666 20 160 Lisa 11-13-1991 Female 777-888-9999 10 199 Joe 07-02-1993 Male 111-222-0000 10 Doctor Id Doctor Room 10 Dr. Wilson 08 20 Dr. Frank 02 Primary Key Foreign Key
  • 17.
    DBMS VS RDBMS DBMS •Introduced in 1960s • Followed navigational modes for data storage • Data fetching is slower for large amount of data • Data redundancy is common in this model leading to difficulty in maintaining data • Examples are dBase, Microsoft Access, LibreOffice Base, FoxPro RDBMS • Introduced in 1970s • Uses relationship between tables using primary keys, foreign keys and indexes • Data fetching is faster because of its relational model • Keys and indexes are used in the tables to avoid redundancy • Example are SQL Server, Oracle, MySQL, MariaDB, SQLite
  • 18.
    RDBMS NORMALIZATION • Databasenormalization or simply normalization, is the process of organizing the data in a database • There are two main goal of normalization process: 1. Eliminating redundant data 2. Ensuring of data dependence • Both of these goals reduce the amount of space a database consumes and ensure that data is logically stored
  • 19.
    BENEFITS OF NORMALIZING •By doing normalization the process of searching and creating tables is faster • More needed tables can be derived for clear vision • Less redundant data and fewer null values will make the database more compact • The indexes of tables make data modification commands execution much faster • Normalization facilitates in reducing data modification anomalies
  • 20.
    SQL JOINS • SQLjoin is a instruction to a database to combine data from more than one table. • There are different type of joins, which have different rules for the results they create. • Types of Joins: 1. Inner join 2. Left outer join 3. Right outer join 4. Full outer join 5. Cross join 6. Self join
  • 21.
    INNER JOIN • TheINNER JOIN or EQUI JOIN creates a new result table by combining column values of two tables (table1 and table2) based upon the join-predicate. • The query compares each row of table1 with each row of table2 to find all pairs of rows which satisfy the join-predicate. • INNER JOIN Script Syntax: SELECT table1.column1, table2.column2 FROM table1 INNER JOIN table2 ON table1.common_field = table2.common_field;
  • 22.
    LEFT OUTER JOIN •A left outer join, or left join, results in a set where all of the rows from the first, or left hand side, table are preserved. The rows from the second, or right hand side table only show up if they have a match with the rows from the first table. • LEFT OUTER JOIN Script Syntax: SELECT table1.column, table2.column FROM table1 LEFT OUTER JOIN table2 ON (table1.column = table2.column);
  • 23.
    RIGHT OUTER JOIN •A right outer join, or right join, is the same as a left join, except the roles are reversed. • All of the rows from the right hand side table show up in the result, but the rows from the table on the left are only there if they match the table on the right. • RIGHT OUTER JOIN Script Syntax: SELECT column_name(s) FROM table1 RIGHT OUTER JOIN table2 ON table1.column_name=table2.column_name;
  • 24.
    FULL OUTER JOIN •A full outer join, or just outer join, produces a result set with all of the rows of both tables, regardless of whether there are any matches. • FULL OUTER JOIN Script Sytax: SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name=table2.column_name;
  • 25.
    CROSS JOIN • TheCARTESIAN JOIN or CROSS JOIN returns the Cartesian product of the sets of records from the two or more joined tables. The row count of the result is equal to the number of rows in the first table times the number of rows in the second table. • CROSS JOIN Script Syntax: SELECT * FROM table1 CROSS JOIN table2;
  • 26.
    SELF JOIN • Joininga table to itself is known as self join. In simple words, it means using a same table twice. • SELF JOIN Script Syntax: SELECT a.column_name, b.column_name FROM table1 a, table1 b WHERE a.common_field = b.common_field;
  • 27.
    REFERENCES • http://docs.oracle.com/cd/E17952_01/index.html • http://www.sql-join.com/ •http://www.mytecbits.com/microsoft/sql-server/what-is-dbms-what-is-rdbms • http://www.tutorialspoint.com/sql/sql-rdbms-concepts.htm • http://databases.about.com/od/specificproducts/a/normalization.htm