Transcript Lecture 27

603 Database Systems
Senior Lecturer: Laurie Webster II,
M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E.
Lecture 27
A First Course in Database Systems
Deductive Databases
Recursive Programming in Datalog:
1.
2.
FollowOn(x,y)  SequelOf(x,y)
FollowOn(x,y)  SequelOf(x,z) AND
FollowOn(z,y)
Rule1 is the basis; it tells us that every sequel is a
follow-on.
Rule 2 says that every follow-on of a sequel of movie
x is also a follow-on of x.
If z is a sequel of x, and we have found that y is a
follow-on of z, then y is a follow-on of x.
Deductive Databases
Recursive Programming in Datalog:
AA 1900-2200
UA 1500-1800
CHI
UA 1830-2130
NY
DEN
AA 1530-1730
UA 930-1230
AA 1500-1930
UA 1400-1700
SF
DAL
AA 900-1430
A Map of Some Airline Flights
Deductive Databases
Recursive Programming in Datalog:
airline from
to
departs
arrives
UA
SF
DEN 930
1230
AA
SF
DAL 900
1430
UA
DEN CHI
1500
1800
UA
DEN DAL 1400
1700
AA
DAL CHI
1530
1730
AA
DAL NY
1500
1930
AA
CHI
NY
1900
2200
UA
CHI
NY
1830
2130
Tuples in
Relation
Flights!
Deductive Databases
Recursive Programming in Datalog:
A predicate whose relation is stored in the database is
called an extension database (EDB)
A predicate for which the corresponding relation is
defined by logical rules is called an intensional
database (IDB)
Deductive Databases
Recursive Programming in Datalog:
Many examples of the use of recursion can be found in
the study of paths in a graph.
The previous slide shows a graph representing some
flights of two hypothetical airlines - Untried
Airlines(UA), and Arcane Airlines (AA) -- among the
cities of San Francisco, Denver, Dallas, Chicago, and
New York.
Deductive Databases
Recursive Programming in Datalog:
Flights are represented by and EDB relation:
Flights(airline, from, to, departs, arrives)
The tuples in the relations are shown in the previous
table
Deductive Databases
Recursive Programming in Datalog:
The simplest recursive question we can ask is:
“For what pairs of cities (x, y) is it possible to get from city x to
city y by taking one or more flights?”
The following two rules describe a relation Reaches(x,y)
that contains exactly these pairs of cities:
1.
Reaches(x,y)  Flights(a,x,y,d,r)
2.
Reaches(x,y)  Reaches(x,z) AND Reaches(z,y)
Deductive Databases
Recursive Programming in Datalog:
1.
Reaches(x,y)  Flights(a,x,y,d,r)
The first rule says that Reaches contains those pairs of cities
for which there is a direct flight from the first to the second;
The airline a, departure time d, and arrival time r are arbitrary
in this rule.
The Deductive Databases
Recursive Programming in Datalog:
2.
Reaches(x,y)  Reaches(x,z) AND Reaches(z,y)
The second rule says that if you can reach from city x to city z
and you can reach from z to y, then you can reach from x to y.
To evaluate the relation Reaches, we begin by using Rule (1)
Deductive Databases
Recursive Programming in Datalog:
To evaluate the relation Reaches, we begin by using Rule (1)
1.
Reaches(x,y)  Flights(a,x,y,d,r)
we get (SF, DEN), (SF, DAL), (DEN,CHI) (DEN,DAL),
(DAL,CHI), (DAL, NY), and (CHI, NY) => seven pairs
represented by arcs in graph
Deductive Databases
Recursive Programming in Datalog:
In the next round we apply recursive Rule (2)
2.
Reaches(x,y)  Reaches(x,z) AND Reaches(z,y)
to put together pairs of arcs such that the head of one is the tail
of the next.
This yields additional pairs (SF,CHI), (DEN, NY), and (SF,NY)
Deductive Databases
Recursive Programming in Datalog:
The third round combines all one- and two-arc pairs
together to form paths of length up to four arcs.
Here we get no new pairs.
The relation Reaches thus consists of the ten pairs
(x,y) such that y is reachable from x in the diagram
Deductive Databases
Recursive Programming in Datalog:
A more complicated definition of when two flights can
be combined into a longer sequence of flights is to
require that the second leaves an airport at least an
hour after the first arrives at that airport.
Now we can use IDB predicate, which we can call
Connects(x,y,d,r).
Deductive Databases
Recursive Programming in Datalog:
Connects(x,y,d,r) says that we can take one or more
flights, starting at city x at time d and arriving at city y
at time r.
The rules for Connects are:
1.
Connects(x,y,d,r)  Flights(a,x,y,d,r)
2.
Connects(x,y,d,r)  Connects(a,z,y,d,t1) AND
Connects(z,y,t2,r) AND
t1 <= t2 - 100
Rough Set Theory and Databases
Rough Set Information System:
Q
U
a1
x1
.
.
Xn
A
D
a2
d
Rough Set Theory and Databases
Rough Set Information System:
The information system is a database-like system
This information system is a new tool to deal with
knowledge acquisition under uncertainty
This information system is called Rough Set Theory
Rough Set Information System:
Rough Set Information System
The main advantage of Rough Set Theory is that it
does not need any preliminary or additional
information about the datalike probability in Statistics
like basic probability number in D-S Theory of
Evidence
like grade of membership or the value of
possibility in fuzzy set theory
Rough Set Information System
Rough Set Theory :
Rough set theory has successfully implemented in
knowledge-based systems
- in medicine
- in industry
- etc.
Rough Set Information System
Rough Set Theory:
The information systems represents what is called
“instance space” in learning from examples
The concept of a rough set is a mathematical tool to
deal with -uncertain and imprecise data
Rough Set Theory offers a new insight and efficient
algorithm
Rough Set Information System
Rough Set Theory:
In rough set theory each imprecise concept is replaced
by a pair of precise concepts - lower approximations
and upper approximations
Deductive Databases
Next Lecture
Rough Set Theory
and Database