42
DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management System (DBMS):- Database management system is basically record computer based record keeping system. Advantage of DBMS:- Database systems help:- 1. Reduce Data Redundancy , 2. Controlled Data Inconsistency , 3. Facilitate To Sharing Of Data , 4. Standardization Of Data, 5. Data Security . 6. Integrated Data.

DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Embed Size (px)

Citation preview

Page 1: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

DATABASE CONCEPTS

Definition:- Database:- A database is a collection of interrelated

data stored together to serve multiple applications; Database Management System (DBMS):-

Database management system is basically record computer based record keeping system.

Advantage of DBMS:- Database systems help:- 1. Reduce Data Redundancy, 2. Controlled Data Inconsistency, 3. Facilitate To Sharing Of Data, 4. Standardization Of Data, 5. Data Security. 6. Integrated Data.

Page 2: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Database Security:- Data Security refers to protection of data

against accidental or intentional discloser to unauthorized persons, or unauthorized modification or destruction.

Database Privacy:- Privacy of data refers to the rights of

individuals and organizations to determine for themselves when, how, and to what extent information about them is to be transmitted to others.

Page 3: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

DATA ABSTRACTION Definition:- A good database system ensures easy, smooth and efficient data structures in such a way so that every type of database user: End users (Computer untrained users, at view level ), Application system (at logical level), Storage system analyst (at internal level or physical implementation ),

is able to access its desired information efficiently

Page 4: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Data Abstraction Type Data Abstraction Type (Various levels of database (Various levels of database

Implementation )Implementation )There are three levels of data abstraction:-There are three levels of data abstraction:-

1.1. Internal Level (Physical level)Internal Level (Physical level)

2.2. Conceptual levelConceptual level

3.3. External level (View level)External level (View level)

Page 5: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Internal level (Physical Level):-Internal level (Physical Level):- The lowest level of data The lowest level of data abstraction, the internal level, is the one closet to physical abstraction, the internal level, is the one closet to physical storage. It describes:-storage. It describes:-

How the data are actually stored in storage device or medium?How the data are actually stored in storage device or medium? What will be the storage technique?What will be the storage technique? What will be the starting address of the database?What will be the starting address of the database?

Conceptual Level:-Conceptual Level:- It is next higher level of internal level. It is next higher level of internal level. In this level data abstraction describe:-In this level data abstraction describe:-

What data are actually stored in the database? What data are actually stored in the database? What all the constitute the database?What all the constitute the database? What are the relationships between the data entities? What are the relationships between the data entities?

External level (View Level):-External level (View Level):- This is the level closet to the This is the level closet to the users and is concerned with the way in which the data are users and is concerned with the way in which the data are viewed by individual users . It describes:-viewed by individual users . It describes:-

What is the way of viewing information to the concerned user?What is the way of viewing information to the concerned user?

Page 6: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Three levels of Data Abstraction Diagrams

View 3View 2 View --- nView 1 . . . .

Conceptual Level

Internal Level

External Level

Conceptual Level

Physical Level

External Level

Page 7: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

View 1

School_record

View 2

Student_detail

Conceptual Roll_No Number(3) Not NullName Char(10)Class Number(3)Grade Char(2)Address Vachar2(10)

Internal

Student_record Length=40Roll_No Type= Byte(6), offset=0,index=IxName Type= Byte(10), offset=0Class Type= Byte(6), offset=0Grade Type= Byte(2), offset=0Address Type= Byte(10), offset=0

School Principal Teacher

External level (Individual User Views)

(Application programs are used to fetch the desired information)

Fig. Illustration of various level with example

Page 8: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Data Independence

The ability to modify a scheme definition in one level without affecting a scheme definition in the next higher level is called Data Independence.

There are two levels of data independence:1. Physical Data Independence:- It is refers to ability to modify the

scheme followed at the physical level without affecting the scheme followed by the conceptual levels.

2. Logical Data Independence:- It is refers to ability to modify the conceptual scheme without causing any changes in the scheme followed at the view levels.

Note:- • It is more difficult to achieve logical data independence rather than the

physical level data independence.• The abstract data types in modern programming language implement

concept of data independence to large extent.

Page 9: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

DATA MODELSDATA MODELSModel refers to the representation way of data or Model refers to the representation way of data or information in the database management system.information in the database management system.

The three data models that are used for The three data models that are used for database management are:- database management are:-

Relational data model.Relational data model. Hierarchical data model.Hierarchical data model. Network data model.Network data model.

Page 10: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Relational data modelRelational data model Relational data model:-Relational data model:- The relational represents The relational represents

data and relationships among data by a collection of tables known as data and relationships among data by a collection of tables known as relationsrelations

Network data model:-Network data model:- Network Data model is Network Data model is represented by collection of records and relationships among data represented by collection of records and relationships among data are represented by link.are represented by link.

Hierarchical data modelHierarchical data model:-:-The hierarchical model is The hierarchical model is similar to the network model in the sense that data and relationships similar to the network model in the sense that data and relationships among data are represented by records and links respectively. It is among data are represented by records and links respectively. It is differs from the network model in that the records are organized as differs from the network model in that the records are organized as collections of trees rather than arbitrary graphs.collections of trees rather than arbitrary graphs.

Roll_No# Student_Name Class Grade

110001 Shyam Sunder 11 A

110002 Krishna 12 A+

Page 11: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Relational Database TerminologyRelational Database Terminology The relational model was propounded by E.F. Codd of IBM and has The relational model was propounded by E.F. Codd of IBM and has

since been acknowledged as a very important concept in DBMS since been acknowledged as a very important concept in DBMS technology.technology.

The relational model has established itself as the primary data model The relational model has established itself as the primary data model for commercial data processing application. for commercial data processing application.

Relation:-Relation:- A Relation is a table i.e. data arranged in rows and columns. A Relation is a table i.e. data arranged in rows and columns. Domain:-Domain:- A Domain is pool of values from which the actual values A Domain is pool of values from which the actual values

appearing in given column are drawn. Exp. Roll_No# , Student_Name appearing in given column are drawn. Exp. Roll_No# , Student_Name etc. etc.

Tuple:-Tuple:-The rows of tables (relations) are generally referred to as Tuple.The rows of tables (relations) are generally referred to as Tuple. Attributes:-Attributes:-The columns of tables (relations ) are generally referred to The columns of tables (relations ) are generally referred to

as attributes.as attributes. Degree:-Degree:- The number of columns (attributes ) in a relation determine The number of columns (attributes ) in a relation determine

the degree of a relation.the degree of a relation. Cardinality:-Cardinality:- The number of tuples (rows) in a relation is called the The number of tuples (rows) in a relation is called the

cardinality of the relation cardinality of the relation

Page 12: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Database KeysIt is important to be able to specify how rows in a relation are distinguished conceptually, rows are distinct from one another. Database perform following keys:-

1. Primary Key

2. Candidate Key

3. Alternate Key

4. Foreign Key

5. Referential Integrity

Page 13: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Definition of Keys Primary Key:- A primary key is a set of one or more attributes

that can uniquely identify tuples (rows) within the relation/table. For example, Roll_no# is a primary key of “student_rec” table.

Candidate Key:- All attributes combines inside a relation that can serve as a primary key are Candidate Keys as they are candidates for the primary key position.

Alternative Key:- A candidate key that is not the primary key is called an alternative key. For example, student_name is a alternative key in “student_rec” table.

Foreign Key:- A non key attribute, whose values are derived from the primary key of some other table, is known as Foreign Key in its current table.

Referential Integrity:-Referential Integrity is a system of rules that a DBMS uses to ensure that relationships between records in related tables are valid, and that users don’t accidentally delete or change related data.

Page 14: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

View:- View is a (virtual) table that does not really exist in its own right but it is instead derived from one or more underlying base table(s).Views are like windows through which you view desired information that is actually stored in a base table.

Normalization:- Normalization is the process of transformation of the

conceptual schema (logical data structures) of the database into a computer representable from.

In other words, the normalization process helps in attaining good database design thereby avoiding undesirable things like repetition of information, inability to represent information, loss of information etc.

Page 15: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Type of Normalization First Normalization:- A relation R is in first

normal form(1NF) if and only if all underlying domains of the relation contain atomic (indivisible ) values.

I-NF perform following:-1. Removing all repeating groups form the relation.2. Decompose non-atomic attributes to atomic attributes.3. All key attributes defined and all attributes depends on

primary key.Fig.—

Page 16: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Second Normal Form (2NF):-A relation R is in Second Normal Form(2NF) if and only if it is 1NF and every non key attribute is fully dependent on the primary key. 2NF perform following:-

1. In I-NF. and Includes no partial dependencies.2. Still possible to exhibit transitive dependencies.Fig.—

Page 17: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Third Normal Form (3NF):-A relation R is in Third Normal Form(3NF) if and only if it is 2NF and every non key attribute is non transitively dependent upon the primary key. 2NF perform following:-

In 2-NF and Contains no transitive dependencies

Page 18: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Boyce - Codd Normal Form (BCNF):-Boyce - Codd Normal Form (BCNF):-A relation R is in Boyce - Codd Normal Form(2NF) if and only if it is 3NF and all of its determinants are candidate keys .

BCNF perform following:-•In 3NF.•Every determinant in the table is a candidate key.

Page 19: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Advantage of Advantage of NormalizationNormalization It reduces data redundancies.It reduces data redundancies. It help eliminate data anomalies.It help eliminate data anomalies. It produces controlled redundancies to link tables.It produces controlled redundancies to link tables.

Need of Normalization:Need of Normalization:-- Normalization is Normalization is needs for :-needs for :-

Most databases to grow by adding new attributes and Most databases to grow by adding new attributes and new relations.new relations.

For improving a efficiency of database.For improving a efficiency of database. Minimizing the need for rewriting the application Minimizing the need for rewriting the application

programs (Front end)programs (Front end)

Page 20: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Front End and Back End:- Front End:- A front end refers to the client side end i.e. the

end at which request is made. Some popular front end software are:-

Visual Basic (VB) ASP (Active Server Page) Visual C++ Power builder MS-Access

Back End:-A Back End refers to the server side, where the client requests are processed. Some popular back end software are:-

SQL Server. Oracle Sybase My SQL etc.

Page 21: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management
Page 22: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

OracleOracle Many DBMSs available in the market that Many DBMSs available in the market that

are capable to storing and maintaining the are capable to storing and maintaining the database of an enterprise. But Oracle is database of an enterprise. But Oracle is one of the most popular DBMS’ s that is one of the most popular DBMS’ s that is being used by millions of organizations being used by millions of organizations across the world.across the world.

Oracle falls under the category of Oracle falls under the category of Relational Database Management System Relational Database Management System (RDBMS).(RDBMS).

History of OracleHistory of Oracle:- The RDBMS Oracle was developed by a company called Relational Software Incorporation (RSI), which was formed in year 1977 by Larry Ellison.

Page 23: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Version of OracleVersion of OracleYear Year Product Status Product Status Product NameProduct Name

19791979 11stst Commercial Product Commercial Product SQL RDBMSSQL RDBMS

19831983 VAX-Mode DatabaseVAX-Mode Database Oracle (In this duration company name changed to Oracle (In this duration company name changed to Oracle Corporation)Oracle Corporation)

19861986 Client-Server databaseClient-Server database Oracle with Server DatabaseOracle with Server Database

19881988 11stst PL/SQL PL/SQL Procedural Language with structural query Procedural Language with structural query languagelanguage

19951995 11stst 64-Bit RDBMS 64-Bit RDBMS Oracle7Oracle7

19971997 11stst Web database Web database Oracle8Oracle8

19991999 11stst Database with JAVA Database with JAVA Oracle8iOracle8i

20012001 11stst Internet developer suite Internet developer suite Oracle 9i with SQLJOracle 9i with SQLJ

20032003 11stst Enterprise Grid Enterprise Grid ComputingComputing

Oracle10Oracle10

20062006 1s database auditing controls1s database auditing controls Oracle11iOracle11i

Page 24: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Features of OracleSome key features of Oracle are:-• Client/Server (Distributed processing) environment.• Large databases and space management.• High availability• Control availability• Manageable security• Portability • Convertibility• Many concurrent database users• Openness, Industry Standard

Page 25: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

The Oracle ServerThe Oracle Server• The Oracle Server is an object-relational database

management system (ORDBMS) that provides an open, comprehensive and integrated approach to information management.Oracle server show in fig.:-

Oracle Sever Consists of :-a. An Oracle database andb. An Oracle instance

Oracle database:-The term database is used to refer to the physical storage of information. The database is stored on the disks attached to the server.

Oracle Instance:-The term instance refers to the software executing on the server that provides access to information stored in the database. The instance runs on the computer or server.

Page 26: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management
Page 27: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Oracle InstanceOracle Instance• Every time a database is started, a”

System Global Area (SGA)” is allotted and Oracle background processes are started. Therefore, Oracle instance has two types of processes:-

•User Processes:- it executes the code of an application program or an Oracle Tool..

•Oracle Processes:- its are server process that perform work for the user process and background processes (oracle background processes: RECO, PMON, SMON, DBWR, LGWR, ARCH ).

Fig.

Page 28: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management
Page 29: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

SGASGASGA:- System Global Area (SGA) is an area of memory used

for database information shared by the database users. SGA consists of three major memory structures :-

1. Database buffer cache2. Shared Pool3. Redo Log buffer.

Background Processes for Oracle Instance, are:-1. Database Writer (DBWR)2. Log Writer (LGWR)3. System Monitor (SMON)4. Process Monitor (PMON)5. Archiver (ARCH) 6. Recoverer (RECO).

Page 30: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Client/Server Architecture Client/Server Architecture • Client /Server computing architectures

generally has a client tier and a server tier, but there can be more tiers also.

• Client/Server model classified into two type:-

1. Two-Tier Computing Model:- 2. Three-Tire Computing Model

Page 31: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Two-Tier Computing ModelTwo-Tier Computing Model

Page 32: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Three-Tire Computing ModelThree-Tire Computing Model

Page 33: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

• Data Dictionary:- The result of compilation of DDL statements is a set of tables which are stored in a special file called data dictionary or directory. A Data Dictionary is a file that contains “Metadata”.

• Metadata:- Data about data called Metadata.• Client:- Client is a end user which request to

central control unit (server) and get desired information from the server.

1. Fat Client:- The client application, which is itself responsible for its processing power and application logic.

2. Thin Client:- The Client application that does not have much of processing power. It only provides a user interface.

• Table Space:- A logical storage unit that comprises of one or more data files.

• Transaction:- A Transaction is one complete unit of work.

Some important Definitions

Page 34: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Accessing Oracle DatabaseOracle provide a wide range of tools for accessing database:-

SQL* Plus:- It is a simplest tool for accessing a Oracle Database. It provide a shell (Command-Line Interpreter) for Oracle (SQL relational query language and programming language PL/SQL).

Designer/2000. Developer/2000 etc.In the following fig. describe other tools which is helpful for accessing of Oracle Database.

Oracle Financials

Oracle Office

Programmer2000

(C&JDBC)

Power Builder

Web Server

Developer 2000

SQL*Plus

Oracle Server

Fig. The Oracle Tools

Page 35: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

SQL( Structured Query Language) First Commercial SQL was released in 1979 by Relational

Software Incorporation (RSI) which is today known as Oracle Corporation. Thus, Oracle is the pioneer RDBMS that started using SQL.

Structured Query Language (SQL) is a language that enables you to create and operate on relational databases.

The Original version of SQL was developed by IBM’s San Jose Research Laboratory (Now Almanden Research Center ). SQL, originally called “Sequel” was implemented as a part of System R Project in early 1970s. The “Sequel” name changed to SQL.

In 1986, the American National Standards Institute (ANSI) published an SQL standard that was updated again in 1992.

SQL has clearly established itself as the standard relational database language.

SQL is the set of commands that is recognized by nearly all RDBMSs.

Page 36: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

SQL SQL (Structural (Structural

Query Query Language)Language)

DDL(Data

Definition Language)

DML(Data

Manipulation Language)

DCL( Data

Control Language)

DRL(Data

Retrieval Language)

TCL ( Transaction

ControlLanguage)

1. Create2. Alter3. Drop

1. Insert 2. Delete3. Update

1. Select 1. Grant2. Revoke

1. Commit 2. Rollback3. Savepoint4. Set Transaction

Page 37: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Oracle ElementsOracle ElementsThe Basic elements of oracle are:-The Basic elements of oracle are:-

1. Schema objects 2. Literals 3. Data types 3. Comments 1. Schema objects:- A schema refers to the

collection of objects or collection of logical structures of data . Schema Objects are the logical structures that directly refer to the database’s data.

Some Schemas Objects are:-1. Tables. 2. Views 3. Clusters 4. Stored Functions 5. Stored Procedures6. Packages 7. Triggers 8.

Indexes

Page 38: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Data TypeData Type1. VARCHAR2(size)2. NUMBER (p, s)3. INTEGER (size)4. DATE5. CHAR (size)6. BOOLEAN7. LONG8. LOB

Page 39: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

SQL Structural query SQL Structural query Language Language

It is classified into five types:-• DDL(Data Definition Language ):- Create ,

Alter, Drop• DML(Data Manipulation Language): Insert ,

delete, update• DCL(Data Control Language):-Grant, Revoke• TCL(Transaction Control Language):- Commit,

Rollback, Savepoint• DRL(Data Retrieval Language):- Select

Page 40: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Joins A join lets us you extract columns from more than

one tables.

A join is a query that combines rows from two or more tables. A join can combine views also.

Note:- In unrestricted join or Cartesian product of two tables, all possible concatenations are formed of all rows of both the tables.

Example. Display details of employee like department name and employee no, employee name from emp and dept table along with.

SQL>SELECT DNAME, ENAME, EMPNO FROM EMP, DEPT;

Using Table Aliases :- A table Alias is a temporary label given along with table name in FROM clause.

Example. Display details of employee like department name, department no, employee no, employee name from emp and dept table along with.

Page 41: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Type of Joins SQL support following type of

Joins - Equi Joins:- The Join , in which columns are compared for equality, is called Equi-Join.

For Example:- Display details like department number, department name, employee name, employee number , job and salary . And ORDER the rows by employee number with department number

SQL> SELECT D.DEPTNO, DNAME, E.DEPTNO,ENAME, EMPNO,JOB,SAL FROM EMP E,DEPT D WHERE E.DEPTNO=D.DEPTNO ORDER BY E.DEPTNO,EMPNO;

Non-Equi Joins:- A Non-Equi join is a query that specifies some relationship other than equality between columns.

Example: SQL> SELECT EMPNO, ENAME,JOB,SAL, DNAME FROM EMP,DEPT WHERE JOB='MANAGER‘;

Page 42: DATABASE CONCEPTS Definition:- Database:- A database is a collection of interrelated data stored together to serve multiple applications; Database Management

Natural Join:- The Join in which only one of the identical columns (combining form joined tables) exists, is called Natural Join.

For Example:- Display details like department number, department name, employee name, employee number , job and salary with only one identical column . And ORDER the rows by employee number with department number

SQL> SELECT E.DEPTNO, DNAME,ENAME, EMPNO,JOB,SAL FROM EMP E,DEPT D WHERE E.DEPTNO=D.DEPTNO ORDER BY E.DEPTNO,EMPNO;

Self Join:- A table joined with itself is called Self Join.

SQL>SELECT E1.*, E2.EMPNO, E2.JOB,E2.DEPTNO WHERE E1.EMP<>E2.EMP