Unary Relation - Database Theory - Homework, Exercises of Introduction to Database Management Systems

In the course of the database theory, we study the key concept regarding the database. The major points in these homework exercises are:Unary Relation, Set of Binary Trees, Binary Relations, Set of Nodes, Fixpoint Expresses, Datalog Programs, Graph Property, Existence of Simple Path, Conjunctive Query, Inflationary Fixpoint Semantics

Typology: Exercises

2012/2013

Uploaded on 04/24/2013

bandhula
bandhula šŸ‡®šŸ‡³

4.7

(10)

91 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE 233 Spring, 2012
Problem Set #5
Due on Thursday, June 7
1. (5 points) Consider the schema consisting of a unary relation Nand two
binary relations C1and C2. Consider the set Bof binary trees represented
by this schema as follows: Nprovides the set of nodes, C1(a, b) means that
bis the first child of a, and C2(a, b) means that bis the second child of a
(each node has zero or two children). Show that fixpoint expresses all ptime
queries over the set of binary trees Brepresented as above.
2. (5 points) In this problem we consider Datalog programs with no con-
stants or (in)equality. We say that a graph property is definable by a Datalog
program Pwith some designated IDB relation answer and one binary EDB
relation Giff for every G,answer is non-empty in P(G) iff the property
holds for G. Show the following:
(i) (3 points) The existence of a path of even length between two desig-
nated nodes aand bin a graph is definable in Datalog.
(ii) (2 points) The existence of a simple path of even length between two
designated nodes aand bin a graph is not definable in Datalog.
3. (4points) Recall that inclusion of Datalog programs is undecidable. Show
that it is decidable, for a conjunctive query ϕand a Datalog program P,
whether Ļ•āŠ†P(i.e., Ļ•(I)āŠ†P(I) for every input I).
4. (6points) Consider the movie database consisting of two relations Schedule[theater,
title] and Movie[title, director, actor]. We do not make the unique director
assumption, so one title may have multiple directors. Consider the query
ā€œList the theaters showing only movies by Hitchcockā€.
(i) (3points) Express the query in Datalog¬with inflationary fixpoint
semantics.
(ii) (3points) Suppose that in addition to the above relations, the database
provides for each attribute A∈ {theater,titl e, actor}a relation succA
providing a successor relation on the set of values of attribute Ain
the database. In addition, assume minAand maxAare constants
1
Docsity.com
pf2

Partial preview of the text

Download Unary Relation - Database Theory - Homework and more Exercises Introduction to Database Management Systems in PDF only on Docsity!

CSE 233 Spring, 2012

Problem Set

Due on Thursday, June 7

  1. (5 points) Consider the schema consisting of a unary relation N and two binary relations C 1 and C 2. Consider the set B of binary trees represented by this schema as follows: N provides the set of nodes, C 1 (a, b) means that b is the first child of a, and C 2 (a, b) means that b is the second child of a (each node has zero or two children). Show that fixpoint expresses all ptime queries over the set of binary trees B represented as above.
  2. (5 points) In this problem we consider Datalog programs with no con- stants or (in)equality. We say that a graph property is definable by a Datalog program P with some designated IDB relation answer and one binary EDB relation G iff for every G, answer is non-empty in P (G) iff the property holds for G. Show the following:

(i) (3 points) The existence of a path of even length between two desig- nated nodes a and b in a graph is definable in Datalog.

(ii) (2 points) The existence of a simple path of even length between two designated nodes a and b in a graph is not definable in Datalog.

  1. (4points) Recall that inclusion of Datalog programs is undecidable. Show that it is decidable, for a conjunctive query Ļ• and a Datalog program P , whether Ļ• āŠ† P (i.e., Ļ•(I) āŠ† P (I) for every input I).
  2. (6points) Consider the movie database consisting of two relations Schedule[theater, title] and Movie[title, director, actor]. We do not make the unique director assumption, so one title may have multiple directors. Consider the query ā€œList the theaters showing only movies by Hitchcockā€.

(i) (3points) Express the query in Datalog¬^ with inflationary fixpoint semantics.

(ii) (3points) Suppose that in addition to the above relations, the database provides for each attribute A ∈ {theater, title, actor} a relation succA providing a successor relation on the set of values of attribute A in the database. In addition, assume minA and maxA are constants

Docsity.com

providing the minimum and maximum values of A. Express the same query using a semi-positive Datalog program.

Docsity.com