• No results found

Logical Database Design.pptx

N/A
N/A
Protected

Academic year: 2020

Share "Logical Database Design.pptx"

Copied!
48
0
0

Loading.... (view fulltext now)

Full text

(1)
(2)
(3)

Two Major Strengths

Simplicity

(4)

Relational Data Model

Presented by E. F. Codd in 1970, then

of IBM

(5)

Relational Data Model

First DBMS built on Relational Data

Model (RDM) was system R

(6)

Basic of RDM

The basic structure is relation

(7)

Basics of RDM

Relations physically represented as tables

Table is a two dimensional representation of a

relation

(8)

Basics of RDM

Columns represent attributes and rows

represent records

Rows, records and tuples all these terms are

(9)

Basic Properties of a Table

1. Each cell of a table contains atomic/single value

2. Each column has a distinct name, the name of the

attribute it represents

3. The values of the attributes come from the same

domain

4. Each row/tuple/record is distinct, no two rows can

(10)

A table

stID stName clName doB

sex

(11)

Components of RDM

As discussed in data model definition

1. Structure (relation/table)

(12)

Mathematical Relations

Consider two sets

A = {x, y} B = {2, 4, 6}

Cartesian product of these sets

(13)

Mathematical Relations

A relation is some subset of this Cartesian

product, For example,

(14)

Mathematical Relations

(15)

Database Relations

Thinking in some real world

scenario

(16)

Database Relations

Cartesian product of Name & Age

Name

X

Age= {(Ali,15), (Sana,15),

(Ahmed,15), (Sara,15), …., (Ahmed,25),

(Sara,25)}

(17)

Database Relations

Let A1, A2, A3, …, A

n

be some

attributes and D1, D2, D3,…, D

n

be

their domains

(18)

Relation Scheme

Can be represented as

R = (A1:D1, A2:D2, ……, An:Dn)

STD = (stId:Text, stName: text, stAdres:Text, doB:Date) OR

(19)

Database Relations

According to this scheme we can

have a relation (instance of this

scheme), like

(20)

Database Relations

STD={(S001, Ali, Lahore, 12/12/76), (S003,

A. Rehman, RWP, 2/12/77)}

stId

stName

stAdres doB

(21)

Relations Keys

The concept of key and all different

types of keys are applicable to the

Relations

(22)

Foreign Key

Consider table EMP and DEPT

(23)

Integrity Constraints

Two main types

Entity integrity constraint

Primary key cannot have null value

Referential integrity constraint

Value of Foreign key is either null or matches with

(24)

Designing Logical DB

Logical DB design is obtained from

conceptual DB design

Generally involves transforming E-R

data model to relational data model

We have studied both DMs, now

(25)

Transforming Rules

Straightforward rules exist

Can be performed manually as well as

automatically

Evaluate even if you use some tool, since

(26)

Mapping Entity Types

Each regular entity type is

transformed straightaway into a

relation

PK of the ET is declared as PK of

relation

(27)

Mapping Entity Types

(28)

Composite Attributes

Since tables can contain only atomic values

(29)

Multi-valued Attributes

An ET with a multi-valued attribute is

transformed into two relations

One contains the entity and second the

(30)

Multi-valued Attribute

The PK of the second relation is the

PK of first relation and the attribute

itself

Values are accessed through

(31)

Multi-valued Attribute

(32)

Mapping Weak ETs

(33)

Mapping Relationships

Relationships are mapped according to their

degree and cardinalities

(34)

Binary Relationships

Cardinality: one to many

The relation against many side ET contains the

(35)

One to Many Example

EMP

PROJ

PROJ(projId, projName, projDur, projCost)

EMP(empId, empName, projId)

(36)

Minimum Cardinality

Minimum cardinality on one side needs

special attention

If optional, define FK as normalIf compulsory, make FK not null

(37)

Minimum Cardinality Example

EMP

DEPT

deptId deptName empName empId empAddr

DEPT(deptId, deptName)

(38)

Many to Many Relationship

A third table is created for the

relationship, sometimes also called

associative entity type

Generally, the PKs of the

(39)

Many to Many

(40)

BOOK

STD

sName stId sFname bkTitle bkId bkAuth

(41)

BOOK

STD

sName stId sFname bkTitle bkId bkAuth isDate rtDate

STD(stId, sName, sFname)

BOOK(bkId, bkTitle, bkAuth)

TRANS(bkId, stId, isDate, rtDate)

(42)

Binary one to one

A special form of one to many

relationship

PK of one ET has to be included in

the other as FK.

(43)

One to One Example

(not from real world)

STD

HOBBY

stName stId stAddr hDur hName

(44)

One to One Example

DEPT

MANAGER

deptName deptId noOfEmp mgrName mgrID

(45)

Unary Relationships

Unary one to many introduces the PK of same

ET as FK

Many to many unary requires creation of

(46)

Unary One to Many Example

EMP

manages empId

empName

eQual

(47)

Unary Many to Many Example

ITEM

has

itemNo iName iCost Qty

ITEM(itemNo, iName, iCost)

(48)

References

Related documents

ceremonial and court ritual in the Sultanate of Oman after the accession of Sultan Qaboos bin Said in 1970.. It will attempt to show that while the creation of rituals of

You are required to have activities from a minimum of 4 categories of recognized methods of learning that are directly related to your practice and/or identified learning goals for

MARINE GRADE HARDWARE - STAINLESS STEEL STD STD STD STD STD STD STD STD STD STD STD STD STD STD BOW ANCHOR ROLLER OPT OPT OPT STD OPT N/A N/A N/A N/A N/A N/A N/A N/A N/A

Tactical Visual Command System (TVCS), is a command and control solution developed by MicroAccess Ltd which can be customized for the military, Law enforcement, emergency

La programació del MSP430 ha estat bastant dura, es tracta d‟una programació a bastant baix nivell on per a qualsevol cosa es necessita una bona lectura del user guide

Use of the CSR Option 2 STID in the Intelligent Mail barcode indicates the mailer has requested forwarding of Bound Printed Matter flats when possible and agrees to pay any

(B) Forward if possible, Traditional ACS notice provided. All other UAA returned to sender - weighted fee due - with reason for non-delivery attached. Traditional ACS notice

Franklin Gothic (The entire font family may be used: ITC Franklin Gothic Std Book, ITC Franklin Gothic Std Book It, ITC Franklin Gothic Std Bk Cd, ITC Franklin Gothic Std Bk CdIt,