Databases



Download 147,44 Kb.
bet6/6
Sana07.09.2021
Hajmi147,44 Kb.
#167210
1   2   3   4   5   6

Data Model - Constraints

  • Constraints express rules that cannot be expressed by the data structures alone:
  • Static constraints apply to database state
  • Dynamic constraints apply to change of database state
  • E.g., “All FLIGHT-SCHEDULE entities must have precisely one DEPT-AIRPORT relationship

Data Model – Constraints (cont.)


FLIGHT#

AIRLINE


WEEKDAY

PRICE


FLIGHT-SCHEDULE

101


delta

mo

156



545

american


we

110


912

scandinavian

fr

450


242

usair


mo

231

Data Model – Constraints (cont.)


DEPT-AIRPORT

FLIGHT#


AIRPORT-CODE

101


atl

912


cph

545


lax

242


bos

Data Model - Operations

  • Operations support change and retrieval of data:
  • insert FLIGHT-SCHEDULE(97, delta, tu, 258); insert DEPT-AIRPORT(97, atl);
  • select FLIGHT#, WEEKDAY
  • from FLIGHT-SCHEDULE

    where AIRLINE=‘delta’;

Data Model – Operations (cont.)


FLIGHT#

AIRLINE


WEEKDAY

PRICE


FLIGHT-SCHEDULE

101


delta

mo

156



545

american


we

110


912

scandinavian

fr

450


242

usair


mo

231


97

delta


tu

258

Data Model – Operations (cont.)


DEPT-AIRPORT

FLIGHT#


AIRPORT-CODE

101


atl

912


cph

545


lax

242


bos

97

atl


Data Model - Operations from Programs

declare C cursor for

select FLIGHT#, WEEKDAY

from FLIGHT-SCHEDULE

where AIRLINE=‘delta’;

open C;

repeat

fetch C into :FLIGHT#, :WEEKDAY;

do your thing;

until done;

close C;

Data Model - Operations from Programs (cont.)


FLIGHT#

AIRLINE


WEEKDAY

PRICE


FLIGHT-SCHEDULE

101


delta

mo

156



545

american


we

110


912

scandinavian

fr

450


242

usair


mo

231


97

delta


tu

258

Keys and Identifiers

  • Keys (or identifiers) are uniqueness constraints
  • A key on FLIGHT# in FLIGHT-SCHEDULE will force all FLIGHT#’s to be unique in FLIGHT-SCHEDULE
  • Consider the following keys on DEPT-AIRPORT:

Keys and Identifiers (cont.)


FLIGHT#

AIRLINE


WEEKDAY

PRICE


FLIGHT-SCHEDULE

101


delta

mo

156



545

american


we

110


912

scandinavian

fr

450


242

usair


mo

231

Keys and Identifiers (cont.)


DEPT-AIRPORT

FLIGHT#


AIRPORT-CODE

101


atl

912


cph

545


lax

242


bos

Integrity and Consistency

  • Integrity: does the model reflect reality well?
  • Consistency: is the model without internal conflicts?
  • a FLIGHT# in FLIGHT-SCHEDULE cannot be null because it models the existence of an entity in the real world
  • a FLIGHT# in DEPT-AIRPORT must exist in FLIGHT-SCHEDULE because it doesn’t make sense for a non-existing FLIGHT-SCHEDULE entity to have a DEPT-AIRPORT

Integrity and Consistency (cont.)


FLIGHT#

AIRLINE


WEEKDAY

PRICE


FLIGHT-SCHEDULE

101


delta

mo

156



545

american


we

110


912

scandinavian

fr

450


242

usair


mo

231

Integrity and Consistency (cont.)


DEPT-AIRPORT

FLIGHT#


AIRPORT-CODE

101


atl

912


cph

545


lax

242


bos

Triggers and Stored Procedures

  • Triggers can be defined to enforce constraints on a database, e.g.,
  • DEFINE TRIGGER DELETE-FLIGHT-SCHEDULE
  • ON DELETE FROM FLIGHT-SCHEDULE WHERE FLIGHT#=‘X’

    ACTION DELETE FROM DEPT-AIRPORT WHERE FLIGHT#=‘X’;

Triggers and Stored Procedures (cont.)


FLIGHT#

AIRLINE


WEEKDAY

PRICE


FLIGHT-SCHEDULE

101


delta

mo

156



545

american


we

110


912

scandinavian

fr

450


242

usair


mo

231

Triggers and Stored Procedures (cont.)


DEPT-AIRPORT

FLIGHT#


AIRPORT-CODE

101


atl

912


cph

545


lax

242


bos
Download 147,44 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish