+ All Categories
Home > Documents > RAJIKA TANDON

RAJIKA TANDON

Date post: 13-Feb-2016
Category:
Upload: malia
View: 36 times
Download: 1 times
Share this document with a friend
Description:
RAJIKA TANDON. DATABASES. CSE 781 – Database Management Systems Instructor: Dr. A. Goel. WHY DATABASE ?. TRADITIONAL METHOD:. In the traditional approach, information is stored in flat files which are maintained by the file system of OS. - PowerPoint PPT Presentation
Popular Tags:
14
RAJIKA TANDON DATABASES CSE 781 – Database Management Systems Instructor: Dr. A. Goel
Transcript
Page 1: RAJIKA TANDON

RAJIKA TANDON

DATABASES

CSE 781 – Database Management Systems

Instructor: Dr. A. Goel

Page 2: RAJIKA TANDON

WHY DATABASE ?

TRADITIONAL METHOD:

File System

Loan_Processing(Application Program) Fixed_Deposit_Processing

(Application Program)

Transaction_Processing(Application Program)

Customer_Details.dat Customer_Loan.dat Customer_Fixed_Deposit.dat Customer_Transaction.dat

•In the traditional approach, information is stored in flat files which are maintained by the file system of OS.

•Application programs go through the file system to access these flat files.

Page 3: RAJIKA TANDON

WITH DATABASE

File System

Loan_Processing(Application Program) Fixed_Deposit_Processing

(Application Program)

Transaction_Processing(Application Program)

DBMS

Bank Database

Customer_DetailsCustomer_Loan

Customer_Fixed_DepositCustomer_Transaction

• DBMS acts as a layer of abstraction on top of the File system.

• You might have observed that, for interacting with the file system, we were using high level language functions for example, the ‘c++’ file handling functions. For interacting with the DBMS we would be using a Query language called SQL.

Page 4: RAJIKA TANDON

ADVANTAGES OF A DBMSData independence Reduction in data redundancy Better security Better flexibility Effective data sharing Enforces integrity constraints Enables backup and recovery

•Users and application programs need not know exactly where or how the data is stored in order to access it.•Proper database design can reduce or eliminate data redundancy and confusion.•Support for unforeseen (ad hoc) information requests are better supported - better flexibility.•Data can be more effectively shared between users and/or application programs.•Data can be stored for long term analysis (data warehousing).

Page 5: RAJIKA TANDON

DATA MODEL

A conceptual tool used to describe

Data

Data relationships

Data semantics

Consistency constraints

Page 6: RAJIKA TANDON

RELATIONAL MODEL Data is viewed as existing in two dimensional tables known as relations

A relation (table) consists of unique attributes (columns) and tuples (rows)

Tuples are unique

Sometimes the value to be inserted into a particular cell may be unknown, or it may have no value. This is represented by a NULL

Null is not the same as zero, blank or an empty string

Relational Database: Any database whose logical organization is based on relational data model.

RDBMS: A DBMS that manages the relational database.

Note:•Though logically data is viewed as existing in the form of two dimensional tables, actually, the data is stored under the file system only.

•The RDBMS provides an abstraction on top of the file system and gives an illusion that data resides in the form of tables.

Page 7: RAJIKA TANDON

KEYS Candidate key

• An attribute, or group of attributes, that is sufficient to distinguish every tuple in the relation from every other one.

• A candidate key is all those set of attributes which can uniquely identify a row. However, any subset of these set of attributes would not identify a row uniquely.

Primary Key • The candidate key that is chosen to perform the identification task is called the

primary key. • Every tuple must have, by definition, a unique value for its primary key. • A primary key which is a combination of more than one attribute is called a

composite primary key .

Page 8: RAJIKA TANDON

KEYS Alternate Key• The candidate key that is chosen to perform the identification task is called the

primary key and the remaining candidate keys are known as alternate keys.• No of Alternate Keys = No of Candidate Keys - 1

Super Key• Any superset of a candidate Key is a super key. • An attribute, or group of attributes, that is sufficient to distinguish every tuple in

the relation from every other one.• For example, a Customer Id,Customer Name (together) can uniquely distinguish

each tuple of the relation from the other ones. Thus it satisfies the property of uniqueness.

• Also Customer Id can alone distinguish each tuple of the relation from the others. Thus it too, satisfies the property of uniqueness.

• Each candidate key is a super key.

Page 9: RAJIKA TANDON

KEYS Foreign Key

• A set of attribute (s) whose values are required to match values of a Candidate key in the same or another table.

• A foreign key is a “copy” of a primary key that has been exported from one relation into another to represent the existence of a relationship between them.

DEPT EMP(Parent /Master/Referenced Table) (Child /Referencing Table)

• Foreign key values do not (usually) have to be unique.• Foreign keys can also be null .

DeptNo DeptNameDN1 EECS

DN2 LLL

EmpNo EmpName EmpDeptNo4001 ESibert DN14002 GBulman DN24003 Paul Null4004 AGoel DN1

Page 10: RAJIKA TANDON

KEYS More About Foreign Key

Foreign key values do not (usually) have to be unique.

Foreign keys can also be null .

A Foreign Key is a set of attributes of a table, whose values are required to match values of some Candidate Key in the same or another table.

The constraint that values of a given Foreign Key must match the values of the corresponding Candidate Key is known as Referential constraint.

A table which has a Foreign Key referring to its own Candidate Key is known as Self-Referencing table.

Page 11: RAJIKA TANDON

KEYS Example of a self-referencing table

Employee TableE# PKENameDateofJoiningSkillSet

Spouse FK

• Consider employees who are also a couple• The primary key field itself will become foreign key in the same table

Employee( E#, EName,…Spouse)

Page 12: RAJIKA TANDON

KEYS Non-Key Attributes

• The attributes other than the Candidate Key attributes in a table/relation are called Non-Key attributes.

• These attributes do not participate in the Candidate key.

Page 13: RAJIKA TANDON

EXERCISE Given a relation R(A,B,C,D) and the following attribute(s) can uniquely

identify the records of relation R.

1) A2) A,D3) C,D

Identify the following in relation R ?

Candidate Key(s) Primary Key Alternate Key Key attribute(s) Non-key attribute(s)

Page 14: RAJIKA TANDON

THANK YOU !!


Recommended