Docsity

Queries for Projects and Suppliers Database - Prof. S. Yurttas, Assignments of Deductive Database Systems

Toggle sidebar
bg1
Summer’2007 – CPSC310-300/CPSC603-300, Dr. Salih Yurtta¸s. [hw-02]
1. Get project names that are supplied by every existing supplier in the
database.
{t| ∃u∈P rojects(t[J Name] = u[JN ame])
∧∀v∈Suppliers
∃w∈Shipments(v[SN] = w[S N]
∧w[JN ] = u[J N])}
{< b >| ∃a, c((< a, b, c >∈P rojects)
∧¬∃d, e, f, g((< d, e, f , g >∈Suppliers)
∧¬∃h, i(< d, h, a, i >∈Shipments)))}
JName
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Queries for Projects and Suppliers Database - Prof. S. Yurttas and more Assignments Deductive Database Systems in PDF only on Docsity!

Summer’2007 – CPSC310-300/CPSC603-300, Dr. Salih Yurtta¸s. [hw-02]

  1. Get project names that are supplied by every existing supplier in the database. {t | ∃u ∈ P rojects(t[JN ame] = u[JN ame]) ∧∀v ∈ Suppliers ∃w ∈ Shipments(v[SN ] = w[SN ] ∧w[JN ] = u[JN ])} {< b >| ∃a, c((< a, b, c >∈ P rojects) ∧¬∃d, e, f, g((< d, e, f, g >∈ Suppliers) ∧¬∃h, i(< d, h, a, i >∈ Shipments)))}

JName

  1. Get supplier names for suppliers who supply ’Red’ parts or parts with size <4. {t | ∃u ∈ Suppliers ∃v ∈ Shipments ∃w ∈ P arts((t[SN ame] = u[SN ame]) ∧(u[SN ] = v[SN ]) ∧(v[P N ] = w[P N ]) ∧(w[Color] =′^ Red′^ ∨ w[Size] < 4)) {< b >| ∃a, c, d((< a, b, c, d >∈ Suppliers) ∧∃e, f, g((< a, e, f, g >∈ Shipments) ∧∃h, i, j, k(< e, h, i, j, k >∈ P arts ∧(i =′^ Red′^ ∨ j < 4))))}

SName Martin Lamb Sarah Cox David Burns David Wood Mary Green Hector Sanchez Richard Phillips Jason Brown Christopher Jordan Donald Long Jeremy Finley Andrew Miller

  1. Get all the relevant info for parts located in ’Dallas’. {t | t ∈ P arts ∧ t[City] =′^ Dallas′} {< a, b, c, d, e >| < a, b, c, d, e >∈ P arts ∧ e =′^ Dallas′}

PN PName Color Size City 1 AAA Yellow 6 Dallas 3 CC Green 7 Dallas 5 EE Red 8 Dallas 6 FF Blue 5 Dallas 7 GGG Blue 2 Dallas 9 II Yellow 4 Dallas 11 K Blue 2 Dallas 13 MM Green 9 Dallas

  1. Get project names supplied by ’Miami’ or ’Boston’ suppliers. {t | ∃u ∈ Suppliers ∃v ∈ Shipments ∃w ∈ P rojects(t[JN ame] = w[JN ame] ∧v[JN ] = w[JN ] ∧v[SN ] = u[SN ] ∧(u[City] =′^ M iami′^ ∨ u[City] =′^ Boston′)} {< h >| ∃a, b, c, d(< a, b, c, d >∈ Suppliers ∧(d =′^ M iami′^ ∨ d =′^ Boston′)) ∧∃e, f, g(< a, e, f, g >∈ Shipments ∧∃i(< f, h, i >∈ P rojects))}

JName

  1. Get status and city for suppliers in ’Houston’. {t | ∃u ∈ Suppliers(t[Status] = u[Status] ∧t[City] = u[City] ∧u[City] =′^ Houston′)} {< c, d >| ∃a, b(< a, b, c, d >∈ Suppliers ∧ d =′^ Houston′)}

Status City 60 Houston 50 Houston 40 Houston

  1. Get project names for ’Blue’ parts used. {t | ∃u ∈ P rojects ∃v ∈ Shipments ∃w ∈ P arts(t[JN ame] = u[JN ame] ∧v[JN ] = u[JN ] ∧v[P N ] = w[P N ] ∧(w[Color] =′^ Blue′)} {< b >| ∃a, c(< a, b, c >∈ P rojects ∧∃d, e, f (< d, e, a, f >∈ Shipments) ∧∃g, h, i, j(< e, g, h, i, j >∈ P arts ∧h =′^ Blue′)))}

SName P P P P P

  1. Get the supplier names of shipments of quntity more than 400. {t | ∃u ∈ Suppliers ∃v ∈ Shipments(t[SN ame] = u[SN ame] ∧u[SN ] = v[SN ] ∧v[Quantity] > 400)} {< b >| ∃a, c, d(< a, b, c, d >∈ Suppliers ∧∃e, f, g(< a, e, f, g >∈ Shipments ∧ g > 400))}

SName Martin Lamb Sarah Cox David Burns David Wood Hector Sanchez Richard Phillips Jason Brown Christopher Jordan Jeremy Finley Andrew Miller