close

Вход

Забыли?

вход по аккаунту

?

The View-Update Problem

код для вставкиСкачать
View Processing & Update
View Processing
create view PresSuite as
select * from Room where NrBeds = 2
select * from PresSuite p natural join Reservation s
where Cost > 85 and ArrivalDate = “10 May”
= select *
from (select * from Room where NrBeds = 2) p
natural join Reservation s
where Cost > 85 and ArrivalDate = “10 May”
View Processing & Optimization
Create view p: пЃіNrBeds = 2 r
Query with view: Cost > 85  ArrivalDate = “10 May” (p |×| s)
Substitute view: Cost > 85  ArrivalDate = “10 May” ((NrBeds = 2 r) |×| s)
Optimize: NrBeds = 2  Cost > 85 r |×| ArrivalDate = “10 May” s
The View-Update Problem
T
D
Dп‚ў
Q
V
Q
U
Vп‚ў
• Q is the query that defines
view V based on database D.
• U is the update specification.
• V is the updated view.
• T is the translator for U, i.e.,
the actual update applied to
D.
• D is the updated database.
Problem: there may be more than one
translator T for a given update specification U.
View-Update Problem – Example
Base
Relations:
r = Guest
G1
View: create view WindowView as
select Guest, RmView
from r natural join s
Room
R1
s = Room
R1
R2
Guest
G1
RmView
Sea
City
RmView
Sea
View Update: update WindowView set RmView = �City’ where Guest = �G1’
Two Translations (ambiguous):
update r set Room = “R2” where Guest = “G1”
update s set View = “City” where Room = “R1”
Updatable Views
When appropriately restricted, view updates work. Often
overly restricted: typically to just пЃ° and пЃі on a single table.
create view PresSuite as
select * from Room where NrBeds = 2
Then:
update PresSuite set Name = “Clinton” where Name = “Nixon”
delete from PresSuite where Name = “Kennedy”
insert into PresSuite values (6, “Bush”, 2, 100)
Документ
Категория
Презентации
Просмотров
0
Размер файла
134 Кб
Теги
1/--страниц
Пожаловаться на содержимое документа