Download as pdf or txt
Download as pdf or txt
You are on page 1of 0

1

RDBMS Concepts
2
Database
Database is an organized collection of data.
Collection of records stored in a systematic way.
Organized for Better Retrieval and Sorting.
3
Types of Database Models
Hierarchical model - Data is organized into a tree-like
structure
Network model - Uses records and sets. Records contain
fields, sets define man-many relationships.
Relational model Geared for OLTP
Dimensional Model Geared for Datawarehousing
Object Relational Model Object Oriented Features
4
Basic Constructs
Tables
Columns
Constraints
Indexes
Views
Procedures
SQL
5
Table & Columns
In a relational database and SQL databases a table is a set of
data elements (values) that is organized using a model of
horizontal rows and vertical columns.
Columns form the attributes of a table. A table consists of
one or more columns. Every RDBMS has a restriction on the
max columns.
Eg: Oracle allows 1000 columns per table
6
Primary Key
Primary key is a value that can be used to identify a unique
row in a table.
Primary key is a candidate key chosen as the main method of
uniquely identifying a tuple in a relation.
Natural Key Key as understood by Business Eg: Associate
Id
Surrogate Key Non Business Key Eg : Sequence Number
7
Primary Key..
Should be immutable, its value should not be changed
during the course of normal operations of the database.
Candidate keys uniquely identifying a row but are likely not
to be immutable.
Primary key should generally be short to minimize data
stored by relations.
Can be a compound consisting on multiple columns.
8
Foreign Keys
A field or group of fields that point to a key field or group of
fields usually in a different table.
In scenarios where a foreign key refers to the same table
itself it is a self key.
Ensures Data Integrity
Eg : Employee Belonging to a Department
9
Foreign Keys Example
ASSOCIATE ID
FIRST NAME
LAST NAME
DEPT NO
Employee
DEPT NO
DEPT NAME
Department
10
Not Nulls
11
Constraint - Not Null
Enforces the need for data to be mandatory.
Applied at column level.
Record cannot be created if value is not supplied.
Eg: First Name is mandatory.
12
Constraint - Check
Enforces the values entered are from a fixed List of Values.
Valid only when a fixed list is present and action is more for
validation.
For variable list a Master Detail with Foreign Keys must be
used.
Eg: A flag indicating the gender M or F.
13
Defaults
Provides for a default value when none is provided.
Useful when user wants to avoid specifying a value every
time.
Eg: Default the date to todays date.
14
Defaults
15
I ndexes
Feature in a database that allows quick access to the rows in
a table.
Smaller than the original table.
Optimized for quick searching.
Eg : Search on the name of an associate
16
SQL Select
Structured Query Language
Way to access data.
Uses simplified English
SQL is a database access, nonprocedural language. Users describe
in SQL what they want done, and the SQL language compiler
automatically generates a procedure to navigate the database and
perform the desired task.
Eg: Get all the employess
Select * from employee
17
SQL Select.
Get all employees whose salary > 5000
Select * from employee where salary > 5000
Get associate id and first name
Select associate_id,first_name from employee
18
Samples of Select
19
SQL Standards
ANSI SQL
The American National Standards Institute (ANSI) has
established a set of industry standards for SQL.
Set of standards which SQL language must be complainant
with.
Database vendors introduce non ANSI complaint features.
Reduction in portability due to non-compliance.
20
SQL J oins
Combines records from two or more tables in a relational
database.
21
Cross J oin
A cross join returns the cartesian product of the sets of rows from
the joined tables.
While not used commonly, a cross join is the foundation upon
which inner joins are built.
SELECT *
FROM employee CROSS J OIN department;
SELECT *
FROM employee,department;
22
I nner J oin
Intersection between the two tables
SELECT * FROM employee ,department
WHERE employee.DepartmentID =department.DepartmentID
23
Left outer join
Instead of limiting results to those in both tables, it limits
results to those in the "left" table
SELECT * FROM employee LEFT OUTER JOIN department ON
employee.DepartmentID = department.DepartmentID
24
Right outer join
Much like a left outer join, except that the tables are reversed
SELECT * FROM employee RIGHT OUTER J OIN department ON
employee.DepartmentID = department.DepartmentID
25
Full outer join
Combines the results of both left and right outer joins.
SELECT * FROM employee FULL OUTER J OIN department ON
employee.DepartmentID = department.DepartmentID
26
SQL I nserts
Adds a record to a table in a relational database.
INSERT INTO table (column1, [column2, ... ]) VALUES (value1,
[value2, ...])
Eg: INSERT INTO phone_book (name, number) VALUES ('J ohn
Doe', '555-1212');
27
SQL Updates
Updates an existing record from a table in a relational
database.
Eg: Update phone_book set name = John Davis where name
='J ohn Doe';
28
SQL Delete
Deletes an existing record from a table in a relational
database.
Eg: Delete phone_book where name = John Davis
29
Commit/Rollback
Signifies the end of a transaction unit.
Commit Means finalize and write all these changes to the
database.
Rollback Revert back all changes made to the database.
Valid from the point when the last commit/rollback was
issued.
30
Transaction
31
SQL Types
DML Data Manipulation Language
Changes to Data
Eg: Select, Insert, Update, Delete
DDL Data Definition Language
Changes to structure
Eg: Create Table
32
Sample Create Table
CREATE TABLE EMP
(
EMPNO NUMBER(9),
ENAME VARCHAR2(10 BYTE),
J OB VARCHAR2(9 BYTE),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2) );
CREATE UNIQUE INDEX PK_EMP ON EMP
(EMPNO);
ALTER TABLE EMP ADD (
CONSTRAINT PK_EMP PRIMARY KEY (EMPNO));
ALTER TABLE EMP ADD (
CONSTRAINT FK_DEPTNO FOREIGN KEY (DEPTNO)
REFERENCES DEPT (DEPTNO));
33
Triggers
Applicable to a table. Way to enforce complex integrity rules
which cannot be implemented by constraints.
Consists of a SQL statements along with procedural
constructs.
Get fired when the relevant condition is met, irrespective of
the source of the transaction.
34
Stored Procedures
A procedure or function is a object that consists of a set of
SQL statements, grouped together, stored in the database
Contains business logic and/or complex logic which cannot
be done by simple SQL
Procedures and functions let you combine the ease and
flexibility of SQL with the procedural functionality of a
structured programming language.
35
Views
Tailored presentation of the data contained in one or more
tables or other views.
Can be thought of as a stored query or a virtual table.
Eg: The employees table has several columns and numerous
rows of information. If you want users to see only five of these
columns or only specific rows, then you can create a view of
that table.
36
Sample View
37
Security
Schema Level Security Login
Object Level Security Tables, Views etc
38
ACI D
Refers to Atomicity, Consistency, Isolation and Durability.
Key properties of any DBMS without which integrity of the
database cannot be guaranteed.
Terms relevant to wrt a Transaction
Transaction is a single logical operation
Eg : Transfer of Funds (consists of multiple steps)
39
Atomicity
Guarantee that either all of the tasks of a transaction are
performed or none of them are.
Transfer of funds can be completed or it can fail for a
multitude of reasons, but atomicity guarantees that one
account won't be debited if the other is not credited as well.
40
Consistency
Database maintains it state when the transaction begins and
when it ends.
Transaction cannot break the rules, or integrity constraints,
of the database.
If an integrity constraint states that all accounts must have a
positive balance, then any transaction violating this rule will
be aborted.
41
I solation
Ability to make operations in a transaction appear isolated
from all other operations.
No operation outside the transaction can ever see the data in
an intermediate state.
Transferred funds can be seen on one account or the other,
but never on botheven if the query runs while the transfer
was still being processed.
42
Durability
Guarantee that once the user has been notified of success,
the transaction will persist, and not be undone.
It will survive system failure, the database has checked the
integrity constraints and won't need to abort the transaction.
43
Architecture Oracle
44
Process Architecture - Oracle
45
Common Databases in Market
Oracle
SQL Server
DB2
Teradata
Sybase
My SQL
46
Group Assignments
Gather Information On..
Supplier
Current Release
Company Stability
Support Infrastructure
Cost Criteria
Operating System Support
Technical Features
Market Penetration
47
Group Presentations
General Information
Each Group will be required to give a 15-30 minute formal presentation
on their chosen topic.
Except for software reviews all research MUST consist of at least three
sources and EVERY GROUP WILL PROVIDE A BIBLIOGRAPHY OF
THEIR REFERENCES at the time of presentation.
Include your thoughts throughout the presentation. NOT just a
short summation at the end.
Fully discuss topic. For example, do not try to discuss all of Oracle
Designer, take a part of it, like the Server Model, or ERD function.
For topics that fall under number 2 and 3, use your own personal
observations.
48
Group Presentations (2)
Possible Topics
1. Asubject scheduledtobediscussedinclass
2. Personal review of a database design tool such as Power Designer,
OracleDesigner, ER-Winetc.
3. Reviewof adatabasesystemsuchasOracle, Sybase, I nformix, etc.
49
Questions and Answers

You might also like