Download - Introduction to RDBMS & SQL
-
8/8/2019 Introduction to RDBMS & SQL
1/25
Introduction to RDBMS & SQL
-
8/8/2019 Introduction to RDBMS & SQL
2/25
Role of Data
Intelligent interpretation of data gives
information Information is vital to the success of an
organization
Not just information, it is right information at
the right time that makes a difference
A DBMS helps in obtaining this information
-
8/8/2019 Introduction to RDBMS & SQL
3/25
Database Management Systems
What is a database system?
A database system is a computer-based record
keeping system whose overall purpose is to
record and maintain information.
It is an electronic filing cabinet.
-
8/8/2019 Introduction to RDBMS & SQL
4/25
Benefits of DBMS
Data redundancy can be reduced
End to data inconsistencies
Enables data sharing
Standards can be set and followed
Data integrity is maintained Data security can be enforced
-
8/8/2019 Introduction to RDBMS & SQL
5/25
Relational Database ManagementSystem
User tables Data
dictionary
Oracleserver
-
8/8/2019 Introduction to RDBMS & SQL
6/25
Relational Database Properties
A relational database:
Can be accessed and modified byexecuting structured query language
(SQL) statements
Contains a collection of tables with no
physical pointers Uses a set of operators
-
8/8/2019 Introduction to RDBMS & SQL
7/25
Entity-Relationship Model
Is based on object-based logical model
Comprises of entities and relationships Is essential to represent the relational
database
-
8/8/2019 Introduction to RDBMS & SQL
8/25
Parts of an E-R Model
Entities - are anything which can be distinctly
identified, like a place, a person, data, aresult or a concept
Attributes - define special characteristics of
an entity
Relationships - can be defined as an
association between the entities
-
8/8/2019 Introduction to RDBMS & SQL
9/25
E-R Diagrams
Are a graphical way of representing entities,
attributes and relationships Easy to understand by everyone
Offer an overview of the entire system
-
8/8/2019 Introduction to RDBMS & SQL
10/25
Types of Relationships
One to One - A pair of tables where one
record from table1 points to one record intable2
One to Many - A pair of tables where one
record from table1 points to many records
in table2, BUT one record from table2points to only one record in table1
-
8/8/2019 Introduction to RDBMS & SQL
11/25
Types of Relationships (Contd.)
Many to Many - Where one record from
table1 points to more than one record intable2 AND one record from table2 points to
more than one record in table1
-
8/8/2019 Introduction to RDBMS & SQL
12/25
SQL Statements
Data Retrieval SELECT
Data Manipulation (DML) INSERT
DELETE
UPDATE
Data Definition (DDL) CREATE ALTER
DROP
RENAME
-
8/8/2019 Introduction to RDBMS & SQL
13/25
Basic SELECT Statement
SELECT *|{column|expression [alias],...}
FROM table;
SELECT identifies whatcolumns
FROM identifies which table
-
8/8/2019 Introduction to RDBMS & SQL
14/25
SELECT *FROM departments;
Selecting All Columns
-
8/8/2019 Introduction to RDBMS & SQL
15/25
Selecting Specific Columns
SELECT department_id, location_id
FROM departments;
-
8/8/2019 Introduction to RDBMS & SQL
16/25
Displaying Table Structure
Use the SQL*Plus DESCRIBE command to
display the structure of a table.
DESC[RIBE] tablename
-
8/8/2019 Introduction to RDBMS & SQL
17/25
Limiting Rows Using a Selection
retrieve all employees
in department 90
EMPLOYEES
-
8/8/2019 Introduction to RDBMS & SQL
18/25
Limiting the Rows Selected
Restrict the rows returned by using theWHERE clause.
The WHERE clause follows the FROM
clause.
SELECT *|{column|expression [alias],...}
FROM table
[WHERE condition(s)];
-
8/8/2019 Introduction to RDBMS & SQL
19/25
Using theWHERE Clause
SELECT employee_id, last_name, job_id, department_id
FROM employees
WHERE department_id = 90 ;
-
8/8/2019 Introduction to RDBMS & SQL
20/25
Comparison Conditions
Operator
=
>
>=
=10000
AND job_id =CLERK';
-
8/8/2019 Introduction to RDBMS & SQL
24/25
Using the OROperator
ORrequires either condition to be true.ORrequires either condition to be true.
SELECT employee_id, last_name, job_id, salary
FROM employees
WHERE salary >= 10000
OR job_id =CLERK';
-
8/8/2019 Introduction to RDBMS & SQL
25/25
SELECT last_name, job_id
FROM employees
WHERE job_idNOT IN ('IT_PROG', 'ST_CLERK', 'SA_REP');
Using the NOT Operator