Df117session 2

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 7

Relational Databases

Consists of a collection of tables Unique names for all the tables Each table represents an entity set Entity:-Real world thing Set:- Group of similar entities Entities and their properties are mapped into tables

ASET

Relations
Tables are known as relations Consists of rows and columns
Each row (tuple) represents an entity Each Column (attribute) represents a property

ASET

Example of a Relation

ASET

attributes (or columns)

tuples (or rows)

Attribute Types
The set of allowed values for each attribute is called the domain of the attribute Attribute values are (normally) required to be atomic; that is, indivisible The special value null is a member of every domain

ASET

Relational Database
A database consists of multiple relations These relations may have interrelations Information about an enterprise is broken up into parts student instructor department Bad design: instructor (ID, name, dept_name, salary, building, budget) results in

ASET

repetition of information (e.g., two instructors have the same department)

Good Design

ASET

Keys
Let K be the set of some attributes of relation R So K R K is a superkey of R if values for K are sufficient to identify a unique tuple of each possible relation r(R)
{ID} and {ID,name} are both superkeys of instructor.

ASET

{dept_name}, {dept_name, building} are superkeys for department

Superkey K is a candidate key if K is minimal, Any subset of candidate key must not be a superkey
{ID} is a candidate key for Instructor

One of the candidate keys is selected to be the primary key. Foreign key constraint: Value in one relation must appear in another
Referencing relation Referenced relation

You might also like