RDBMS FUNDAMENTALS 1. A relational database is a collection of data items organized as a set of...

Post on 21-Jan-2016

217 views 0 download

Transcript of RDBMS FUNDAMENTALS 1. A relational database is a collection of data items organized as a set of...

1

RDBMSFUNDAMENTALS

A relational database is a collection of data items organized as a set of formally described tables from which data can be accessed easily.A relational database is created using the relational model. The software used in a relational database is called a relational database management system (RDBMS). A relational database is the predominant choice in storing data, over other models like the hierarchical database model or the network model.

3

Relational Model It is a simple data model in which database is represented as a collection of ‘relations’ ,where each relation is represented by a two dimensional table.

4

Relational Model

5

Relational Terminology

Formal Relational Term Informal Equivalent(s)

Relation Table

Tuple Row, Record

Cardinality Number of rows

Attribute Column, Field

Degree Number of columns

Primary key Unique identifier

Domain Set of legal values

7

RDBMS Concept• Relational Database Management System: A type of database

management system (DBMS) that stores data in the form of related tables.

• Relational databases are powerful because they require few assumptions about how data is related or how it will be extracted from the database. As a result, the same database can be viewed in many different ways.

• The concept of relational databases was given by E.F. Codd at IBM in 1970.

• An important feature of relational systems is that a single database can be spread across several tables.

• This differs from flat-file databases, in which each database is self-contained in a single table.

8

A key uniquely identifies a row in a table. In RDBMS, these are classified into the five:

• Primary Key

• Foreign Key

• Candidate Key

• Alternate Key

• Composite Key

Concept Of Keys In RDBMS

9

• Primary Key : The primary key is a attribute of a relational table uniquely identifies the each tuple of a table or each record in the table. It can either be a normal attribute that is guaranteed to be unique. • Foreign Key : A foreign key is a column in a table that uniquely identifies the records from the different table .

• Candidate Key :  Any number of attributes that are uniquely identifying a row in a table is “candidate key” for the table.

• Alternate Key : We select one of the candidate key as Primary key. All candidate keys which are not chosen as "primary key" are “Alternate keys”. • Composite Key : The key which uniquely identify the rows of the table and which is made up of more than one attribute is called “composite key”.

Concept Of Keys In RDBMS

Two types relationship:one-to-many (1:M)

book-publisherA book has one publisher but a publisher may publish many books

many-to-many (M:M)books-to-authors

A book may have many authors and an author may write many books

Normalization•Normalization was first

proposed by Codd as an integral part of the relational model. It prevents data manipulation anomalies and loss of data integrity. The most common forms of normalization applied to databases are called the normal forms. Normalization trades reducing redundancy for increased information entropy.

First normal form (1NF) sets the very basic rules for an organized database: 

· Eliminate duplicative columns from the same table.

 · Create separate tables for each group of related

data and identify each row with a unique column or set of columns (the primary key). 

Second normal form (2NF) further addresses the concept of removing duplicative data: 

· Remove subsets of data that apply to multiple rows of a table and place them in separate tables.

 · Create relationships between these new tables

and their predecessors through the use of foreign keys.

  

• Third normal form (3NF) goes one large step further: 

· Remove columns that are not dependent upon the primary key.

 Finally, fourth normal form (4NF) has one requirement:

· A relation is in 4NF if it has no multi-valued dependencies.Remember, these normalization guidelines are cumulative. For a database to be in 2NF, it must first fulfill all the criteria of a 1NF database. 

15

ORACLE - RDBMS Software

• The oracle Corporation is the world’s leading supplier of software for information management and world’s second largest independent software company.

• It is the top selling multi-user RDBMS.

• Oracle’s application covers business intelligence, e-commerce , euro , Financials(such as accounts receivables, accounts payable, and general ledger), human resources, internet procurement, manufacturing, mobile, projects, sales, services, strategic enterprise management, and treasury.

15

16

Some more leading RDBMS Products

•SQL Server•IBM’s DB2

• SQL referred to as Structured Query Language is a special-purpose programming language designed for managing data in relational database management systems (RDBMS).

Data manipulation

•The Data Manipulation Language (DML) is the subset of SQL used to add, update and delete data:

• INSERT adds rows (formally tuples) to an existing table.

•UPDATE modifies a set of existing table rows.•DELETE removes existing rows from a table.

Data definition

•The Data Definition Language (DDL) manages table and index structure. The most basic items of DDL are the 

•CREATE, •ALTER, •RENAME, •DROP and •TRUNCATE statements:

CREATE creates an object (a table, for example) in the database.

ALTER modifies the structure of an existing object in various ways, for example, adding a column to an existing table or a constraint.

TRUNCATE deletes all data from a table in a very fast way, deleting the data inside the table and not the table itself. It usually implies a subsequent COMMIT operation, i.e., it cannot be rolled back (data is not written to the logs for rollback later, unlike DELETE).

DROP deletes an object in the database, usually irretrievably, i.e., it cannot be rolled back.

Data control

The Data Control Language(DCL) authorizes users and groups of users to access and manipulate data. Its two main statements are:

GRANT authorizes one or more users to perform an operation or a set of operations on an object.

REVOKE eliminates a grant, which may be the default grant.

  

22

RELATIONAL ALGEBRA• Relational Algebra is a procedural language that can

be used to tell the DBMS how to build a new relation from one or more relations(tables) in the database.

• While using the relational algebra, user has to specify what is required and what are the procedure or steps to obtain the required output.

• It is a theoretical language with operations that work on one or more relations to define another relation without changing the original relation(s).

23

RELATIONAL ALGEBRA

• In Relational Algebra, each operation takes one or more relations as its operand(s) and another as its result.

• That is, in relational algebra, R1 + R2 = R3

where, ‘R1’ & ‘R2’ are relations (operands) ‘+’ is relational operator which gives R3 as a

resultant relation

24

Types of Relational Operators

Relational Operators are classified into two types:

•Traditional Set Operators

•Special Operators

25

Traditional Set Operators

Union

Intersection

Difference

Cartesian Product

26

Union

• In mathematical set theory, the union of two sets is the set of all elements belonging to both sets.

• It is denoted by ‘U’.

• If S1 = {1,2,3,4,5} and S2 = {4,5,6,7,8} Then union of two sets (S1 U S2) would be the set {1,2,3,4,5,6,7,8}

27

In case of union operation on two relational tables…

Suppose there are two tables ‘R’ and ‘S’

R

R U S

C.Name C.Status

A Good

B Excellent

C.Name C.Status

B Excellent

C Bad

S

C.Name C.Status

A Good

B Excellent

C Bad

28

Intersection• In mathematics, an intersection of two sets

produces a set, which contains all the elements common to both sets.

• It is denoted by ‘ ’• If S1 = {1,2,3,4,5} and S2 = {4,5,6,7,8} Then intersection of two sets (S1 S2) would be

the set {4,5}

29

In case of intersection operation on two relational tables…

Suppose there are two tables ‘R’ and ‘S’

R

R intersection S

C.Name C.Status

A Good

B Excellent

C.Name C.Status

B Excellent

C Bad

S

C.Name C.Status

B Excellent

30

Difference• In mathematics, the difference between two sets

produces a set, which contains all the elements of one set, which are not in the other.

• It is denoted by ‘-’• If S1 = {1,2,3,4,5} and S2 = {4,5,6,7,8} Then difference between two sets (S1 - S2) would

be the set {1,2,3} or, (S2 – S1) = {6,7,8}

31

In case of difference operation on two relational tables…

R

R - S

C.Name C.Status

A Good

B Excellent

C.Name C.Status

B Excellent

C Bad

S

C.Name C.Status

A Good

C.Name C.Status

B Excellent

S - R

32

Cartesian Product• In mathematics, the cartesian product of two sets is

the set of all ordered pairs of elements such that the first element in each pair belongs to the first set and the second element in each pair belongs to the second set.

• It is denoted by ‘X’ (cross)• If S1 = {1,2,3} and S2 = {4,5,6} Then the cartesian product (S1 X S2) is the set:

{(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6)}

33

In case of cross (X) operation on two relational tables…

Male_Female

F.Name F.Job

A Clerk

B Sales

M.Name M.Job

C Clerk

D Sales

Male

F.Name F.Job M.Name M.Job

A Clerk C Clerk

A Clerk D Sales

B Sales C Clerk

B Sales D Sales

Female

34

Special (Relational) Operators

Select

Project

Join

35

Select Operation

•It is used to select some specific records from the database based on some criteria.

• It is mathematically denoted as ‘ o ’•Syntax: o <selection condition>(Relation) Example: o age <= 30 (person)

36

Project Operation

•It is used to select the records with specified attributes while discarding the others based on some specific criteria.

• It is mathematically denoted as ‘ ’•Syntax: <selection condition> (Relation) Example: Name (Person)

37

Join Operation

•It is applied on two relations when we want to select related tuples from two given relation.

•It is denoted by | |•Syntax: R1 | | R2 where R1 and R2 are two related

relations•Example: student | | course

What Are the Limitations of Relational Databases in Business Applications?

Relational databases power many different types of business applications, including customer relationship management systems and billing programs. These databases offer powerful information management tools to business leaders, but the technology behind a relational database also imposes limitations. These drawbacks become apparent not only within the database itself, but also in the mechanisms by which business applications access the data.

Data Complexityinexperienced programmers may design systems that create unnecessary complexity or limit the future development of the database through poorly chosen data types.

Broken Keys and RecordsRelational databases require shared keys to link information spread across several tables.If the data types linking the keys are different, the database cannot link the records without additional rework by the report developer.

Developer ExpertiseAs the complexity of a relational database increases, the skill set required by the RDBMS administrator, various users and report developers also increases.

Hardware Performance•Complex queries require sophisticated

processing power. Although most desktop computers can manage the databases of the size and complexity often encountered in a small business setting, a database with external data sources or very complex data structures may require more powerful servers to return results within an acceptable response time.

The benefits of a database that has been designed according to the relational model are numerous. Some of them are:

• Data entry, updates and deletions will be efficient.• Data retrieval, summarization and reporting will also be

efficient.• Since the database follows a well-formulated model, it

behaves predictably.• Since much of the information is stored in the database rather

than in the application, the database is somewhat self-documenting.

• Changes to the database schema are easy to make. 

Summary

• The relational database model was created by E.F. Codd in 1969 and is founded on set theory and logic.

• A database designed according to the relational model will be efficient, predictable, well performing, self-documenting and easy to modify.

• Every table must have a primary key, which uniquely identifies rows in the table.

• Foreign keys are columns used to reference a primary key in another table.

• You can establish relationships between tables in a relational database: one-to-many, many-to-many .

thankyouBy:rajni gupta