0 Voturi pozitive0 Voturi negative

1 (de) vizualizări27 paginiA dedctivw an;ldma;sl asjdpas pl skdlsk sad

Jun 29, 2018

© © All Rights Reserved

DOCX, PDF, TXT sau citiți online pe Scribd

A dedctivw an;ldma;sl asjdpas pl skdlsk sad

© All Rights Reserved

1 (de) vizualizări

A dedctivw an;ldma;sl asjdpas pl skdlsk sad

© All Rights Reserved

- Railway Reservation System
- Data Modeling
- Arena Table Layout
- mca304
- ch-14
- Hotel Managementfinal Report(Print)
- A Logical Temporal Relational Data Model
- RDBMS.Introduction
- Dbms Introduction
- dbms-handbook.doc
- Course - Introduction to Teradata Database
- Lecture_6 Access Notes-1
- DBMS_COURSEFile
- Teradata Architecture
- Deductive Database Xujia
- cam sql lab file.doc
- Computer Finals Reviewer
- DBMS-Syllabus
- Oracle Architecture Basic Questions
- A Framework for Temporal Geographic Information - Gail Langran and Nicholas R. Chrisman

Sunteți pe pagina 1din 27

DATABASE SYSTEM

● Raguman K- 16BCE0917

COURSE CODE:CSE2004

DATABASE MANAGMENT SYSTEMS

SLOT NO : A11+A12

PROFESSOR NAME : Vijayarajan V

ABSTRACT

The convergence of relational database , logic and

artificial intelligence gave birth to deductive

database. A deductive database consists of rules and

facts through a language in which we specify what to

achieve rather than how to achieve . Facts are

specified in a manner similar to the way relations

are specified but it does not include attribute names

rather rules are virtual relations that are not actually

stored but can be implied using implying

mechanism. In deductive database there are two

components: database storage and logic to derive

information . This implies that a database can

conclude additional facts based on rules and facts

stored in the database itself. Deductive database

uses Datalog as its database query language .

Deductive databases are considered to be more

expressive than relational database. Datalog allows

us to write queries as normal logic operations and

are ensured to terminating upon some conditions.

We will be using Datalog Educational System for

highlighting its features and importance over SQL.

What is Datalog?

Datalog is a nonprocedural query language based on

the logic-programming language Prolog. A user

describes the information desired without giving a

specific procedure for obtaining that information.

Datalog simplifies writing simple queries and makes

query optimization easier.

Logical Query Languages

Motivation

Logical rules extend more naturally to

recursive queries than does relational

algebra

Used in SQL recursion

Logical rules form the basis for many

information integration systems and

applications

Meaning of Rules

Head is true of its arguments if there exist values for

local variables those in body not in head that make all

of the subgoals true

If no negation or arithmetic comparisons just natural

join the subgoals and project onto the head variables

Terminology

Variable

A variable is like a variable in a mathematical

equation, it represents some constant that has yet to

be determined.

By convention variables always start with an upper

case letter, e.g., City, Firstname,Code, A, B, C, etc

Constant

A constant is an attribute value. By convention all

constants begin with lower-case letters such as:

sammy, joe, xxy2003, etc

fact

A fact is the same things a tuple in a relation. A fact

has the following structure. (called Ground facts,

because there are no variables)

<predicate name>(<list of constants>)

Example: Facts about student enrollment:

The following set of facts shows some students

and the subjects in which they are enrolled.

enrolledIn(joe, cp2001)

enrolledIn(sue, cp2001)

enrolledIn(joe, cp2003).

In relational database terms, it would be the same

as the following relation. enrolledIn

Rules

A rule is a way to derive new facts. It is part of a query.

A rule has the following form

<head> :-<body>

Head is a single predicate and the body is a list of

predicates. Each predicate has the form

positive literal:<relation name>(<list of constants

variables>)

negative literal:not <relation name>(<list of constants

or variables>)

What does :- mean?

Assume we have a rule: Q :- P

Then :- means, if P is true then Q is true

Evaluation of Rules

Two dual approaches

Variablebased- Consider all possible assignments of

values to variables. If all subgoals are true add the head

to the result relation.

Tuplebased -Consider all assignments of tuples to

subgoals that make each subgoal true. If the variables

are assigned consistent values add the head to the

result.

The following rule identifies courses students are

enrolled in.

result(Name, Code, Phone) :- student(Name, Phone),

enrolledIn(Name, Code).

Student

Name Phone

joe 408-489-

5454

enrolledIn

Name Code

joe CP2004

sue CP2001

joe CP2003

that unifies

student(joe,408-489-5454), enrolledIn(joe,

CP2004)

student(joe,408-489-5454), enrolledIn(sue,

CP2001)

student(joe,408-489-5454), enrolledIn(joe,

CP2003)

Result:

result(joe, CP2004, 408-489-5454)

result(joe, CP2003, 408-489-5454)

Safety

It may be possible to write rules that generate an an

infinite number of answers. For example:

employee(X,Y) :- X>Y

Since the relation defining > is infinite, this rule would

generate an infinite number of facts for the relation

employee. Also the use of negation can cause similar

problems. For example:

not-in-loan(L, B, A) :- not loan(L, B, A)

We want to retrieve all tuples that are not in the loan

relation but if account numbers, branch-name and

balance is infinite then the relation not-in-loan would

also be infinite.

To avoid such problems Datalog rules are required to

satisfy the following safety conditions:

1. Every variable that appears in the head of the rule

also appears in a nonarithmetic positive literal in the

body of the rule

2. Every variable appearing in a negative literal in the

body of the rule also appears in some positive literal in

the body of the rule.

Recursion in Datalog

Suppose now that we want to find out which

employees are supervised, directly or indirectly by a

given manager, "Jones".

(1) People whose manager is "Jones"

(2) People whose manager is supervised by "Jones"

Ex. Tim manager is Jones

Kelly manager is Tim

employee-jones(X) :- manager(X, "Jones")

employee-jones(X) :- manager(X,Y), employee-jones(Y)

Procedure

I = set of facts in the database

repeat

Old_I = I

I = I U infer( R, I)

until I = Old_I

employee-jones(X) :- manager(X, "Jones")

employee-jones(X) :- manager(X,Y), employee-jonesY

Manager relation

employee- manager-

name name

Alon Barinsky

Barinsky Estovar

Corbin Duarte

Duarte Jones

Estovar Jones

Jones Klinger

Rensal Klinger

Iteration Tuples in

employee-

jones

1 (Duarte),

(Estovar)

2 (Duarte),

(Estovar),

(Barinsky),

(Corbin)

3 (Duarte),

(Estovar),

(Barinsky),

(Corbin),

(Alon)

4 (Duarte),

(Estovar),

(Barinsky),

(Corbin),

(Alon)

Recursive Rules

body of rules, we can express an in finite union in

Datalog. We shall first see some examples of how to

express recursions in Datalog. In Section 10.3.2 we

shall examine the least endpoint computation of the

relations for the IDB predicates of these rules. A new

approach to rule-evaluation is needed for recursive

rules, since the straight-forward rule-evaluation

approach of Section ?? assumes all the predicates in

the body of rules have relations.

FollowOn by the following two Datalog rules:

is a follow-on. The second rule says that every follow-

on of a sequel of movie x is also a follow-on of x. More

precisely: 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. 2

To evaluate the IDB predicates of recursive Datalog

rules, we follow the principle that we never want to

conclude that a tuple is in an IDB relation unless we

are forced to do so by applying the rules Thus, we:

progressively larger relations are constructed for

the IDB predicates. In the bodies of the rules, use

the IDB relations constructed on the previous

round. Apply the rules to get new estimates for all

the IDB predicates.

component value that does not also appear in

some EDB relation. Thus, there are a finite

number of possible tuples for all IDB relations,

and eventually there will be a round on which no

new tuples are added to any IDB relation. At this

point, we can terminate our computation with the

answer; no new IDB tuples will ever be

constructed.

movie sequel

Rocky Rocky II

Rocky

Rocky II III

Rocky

Rocky III IV

At the first round of computation, FollowOn is

assumed empty. Thus, rule (2) cannot yield any

FollowOn tuples. However, rule (1) says that every

SequelOf tuple is a FollowOn tuple. Thus, after the first

round, the value of FollowOn is identical to the

SequelOf relation above.

In the second round, we use the relation as FollowOn

and apply the two rules to this relation and the given

SequelOf relation. The first rule gives us the three

tuples that we already have, and in fact it is easy to see

that rule (1) will never yield any tuples for FollowOn

other than these three. For rule (2), we look for a

tuple from SequelOf whose second component equals

the first component of a tuple from FollowOn.

Thus, we can take the tuple (Rocky; Rocky II) from

SequelOf and pair it with the tuple (Rocky II; Rocky

III) from FollowOn to get the new tuple (Rocky; Rocky

III) for FollowOn. Similarly, we can take the tuple

(Rocky II; Rocky III)

FollowOn to get new tuple (Rocky II; Rocky IV) for

FollowOn. However, no other pairs of tuples from

SequelOf and FollowOn join. Intuitively, just as (a)

contains only those follow-on facts that are based on a

single sequel,(b) contains those follow-on facts based

on one or two sequels.

In the third round, we use the relation FollowOn and

again evaluate the body of rule (2). We get all the

tuples we already had, of course, and one more tuple.

When we join the tuple (Rocky; Rocky II) from

SequelOf with the tuple (Rocky II; Rocky IV) from the

current value of FollowOn, we get the new tuple

(Rocky; Rocky IV).

When we proceed to round 4, we get no new tuples, so

we stop.

There is an important trick that simplifies all

recursive Datalog evaluations, such as the one above:

At any round, the only new tuples added to any IDB

relation will come from applications of rules in which

at least one IDB sub-goal is matched to a tuple that

was added to its relation at the previous round.

x y

Rocky Rocky II

Rocky

Rocky II III

Rocky

Rocky III IV

xy

Rocky Rocky II

Rocky

Rocky II III

Rocky

Rocky III IV

Rocky

Rocky III

Rocky

Rocky II IV

xy

Rocky Rocky II

Rocky

Rocky II III

Rocky

Rocky III IV

Rocky

Rocky III

Rocky

Rocky II IV

Rocky

Rocky IV

goals be matched to told" tuples, the tuple of the head

would already have been added on the previous

round. The next two examples illustrate this strategy

and also show us more complex examples of

recursion.

Other Forms of Recursion

the recursion, where the use of the recursive

relation FollowOn appears after the EDB relation

SequelOf. We could also write similar left-

recursive rules by putting the recursive relation

first. These rules are:

1. FollowOn(x,y) SequelOf(x,y)

sequel of x or a sequel of a follow-on of x.

as in the nonlinear recursion:

1. FollowOn(x,y) SequelOf(x,y)

sequel of x or a follow-on of a follow-on of x. All

three of these forms give the same value for

relation FollowOn: the set of pairs (x; y) such that

y is a sequel of a sequel of

2)

Many examples of the use of recursion can be found in

a study of paths in a graph. Figure 10.2 shows a

relation representing some flights of two hypothetical

airlines | United Airlines (UA), and Arrow Airlines

(AA) | among the cities San Francisco, Denver, Dallas,

Chicago, and New York.

Flights(airline, from, to, departs, arrives)

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.

Reaches(x,y) Flights(a,x,y,d,r)

of cities for which there is a direct light from the first

to the second; the airline a, departure time d, and

arrival time r are arbitrary in this rule. 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. Notice that we have used the nonlinear form of

recursion here, as was described in the box on \Other

Forms of Recursion." This form is slightly more

convenient here, because another use of Flights in the

recursive rule would involve three more variables for

the unused components of Flights.

We begin by using Rule (1) to get the following pairs

in Reaches: (SF, DEN), (SF, DAL), (DEN, CHI), (DEN,

DAL), (DAL, CHI), (DAL, NY), and (CHI, NY). These are

the seven pairs represented by arcs in Fig. below.

In the next round, we apply the recursive Rule (2) to

put together pairs of arcs such that the head of one is

the tail of the next. That gives us the additional pairs

(SF, CHI), (DEN, NY), and (SF, NY). The third round

combines all one- and two-arc pairs together to form

paths of length up to four arcs. In this particular

diagram, 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 of Fig. above .

Because of the way we drew the diagram, these pairs

happen to be exactly those (x; y) such that y is to the

right of x in Fig

airline from to departs arrives

3)

A more complicated problem 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 use

an IDB predicate, which we shall call Connects(x,y,d,r),

that says we can take one or more flights, starting at

city x at time d and arriving at city y at time r. If there

are any connections, then there is at least an hour to

make the connection.

The rules for Connects are

1. Connects(x,y,d,r) Flights(a,x,y,d,r)

Connects(z,y,t2,r) AND

t1 <= t2 – 100

facts shown above the first line in Fig.. Each

corresponds to one of the flights indicated in the

diagram of Fig.

We now try to combine these tuples using Rule (2).

For example, the second and fifth of these tuples

combine to give the tuple (SF, CHI, 900, 1730).

However, the second and sixth tuples do not combine

because the arrival time in Dallas is 1430, and the

departure time from Dallas, 1500, is only half an hour

later. The Connects relation after the second round

consists of all those tuples above the first or second

line in Fig. Above the top line are the original tuples

from round 1, and the six tuples added on round 2 are

shown between the first and second lines.

In the third round, we must in principle consider all

pairs of tuples above one of the two lines in Fig. as

candidates for the two Connects tuples in the body of

rule (2). However, if both tuples are above the first

line, then they would have been considered during

round 2 and therefore will not yield a Connects tuple

we have not seen before. The only way to get a new

tuple is if

at least one of the two Connects tuple used in the body

of rule (2) were added at the previous round; i.e., it is

between the lines in Fig.The third round only gives us

three new tuples. These are shown at the bottom of

Fig.. There are no new tuples in the fourth round, so

our computation is complete.

x y D r

SF CHI 930 1800

SF NY 900 2130

SF NY 900 2200

SF NY 930 2200

where things don't work as well. Suppose we have a

single EDB predicate R. This predicate is unary (one-

argument), and it has a single tuple, (0). There are two

IDB predicates, P and Q, also unary. They are de ned

by the two rules

AN NO

1. P(x) R(x) D T Q(x)

AN NO

2. Q(x) R(x) D T P(x)

is either in P or in Q but not both. Notice that P and Q

are de ned recursively in terms of each other.

When we de ned what recursive rules meant in

Section 10.3.2, we said we want the least endpoint,

that is, the smallest IDB relations that contain all

tuples that the rules require us to allow. Rule (1),

since it is the only rule for P , says that as relations, P =

R ,Q, and rule (2) likewise says that Q = R ,P . Since R

contains only the tuple (0), we know that only (0) can

be in either P or Q. But where is (0)? It cannot be in

neither, since then the equations are not satisfied; for

instance P = R , Q would imply that ; = f(0)g which is

false.

If we let P = f(0)g while Q =R ;, then we do get a solution to both equations.

R , P becomes ; = f(0)g , f(0)g, which is also true.

choice too satisfies both rules. We thus have two

solutions:

a)P = f(0)g Q =R ;

b) P = ;R Q = f(0)g

Both are minimal, in the sense that if we throw any tuple out of any

relation, the resulting relations no longer satisfy the rules. We cannot,

therefore, decide between the two least endpoints (a) and (b), so we cannot

answer a simple question such as \Is P (0)

We saw that our idea of defining the meaning of recursive rules by finding

the least endpoint no longer works when recursion and negation are

tangled up too intimately. There can be more than one least endpoint, and

these endpoints can contradict each other. It would be good if some other

approach to defining the meaning of recursive negation would work better

predicate A in the head has a negated sub-goal

with predicate B. Label this arc with a , sign to

indicate it is a negative arc.

head predicate A has a non-negated sub-goal with

predicate B. This arc does not have a minus-sign

as label.

negative arcs, then the recursion is not strati ed.

Otherwise, the recursion is strati ed. We can group the

IDB predicates of a stratifiIed graph into strata. The

stratum of a predicate A is the largest number of

negative arcs on a path beginning from A.

UA only

AA reaches

UA reaches

Related Works

[1] Faiz Arni, KayLiang Ong, Shalom Tsur, Haixun

Wang, and Carlo Zaniolo. The Deductive Database

System LDL++.

Describes the execution model and the open architecture

designed to integrate with existing DBMS and it’s

applications

Gordon. Design and Semantics of a Decentralized

Authorization Language.

It presents a language which balances semantic and

syntactic simplicity and efficiency

P. L´opez-Garc´ıa, and G. Puebla. The Ciao Prolog

system.

It is a system which supports logic, constraint and object

oriented styles.it has high power and efficiency.

[4] R. Caballero, Y. Garc´ıa-Ruiz, and F. S´aenz-P´erez.

A Theoretical Framework for the Declarative

Debugging of Datalog Programs.

Debugging starts when user detects unexpected answer

for a query and ends with debugger pointing at error.

Computations for debugging in datalog are represented as

graphs rather than much used trees.

Applying Constraint Logic Programming to SQL Test

Case Generation.

Applying constraint will automatically give you the

domain. This technique is checked with respect to

extended relational algebra.

[6] “Foundations of Databases” by Abiteboul, Hull, Vianu,

Ch.

[7] . A basis for deductive database systems II JW Lloyd,

RW Topor - The Journal of Logic Programming

[8].Arni, F., Ong, K., Tsur, S., Wang, H., Zaniolo, C. (2003)

The Deductive Database System LDL++.

[9].Fikes, R., Hayes, P.J., Horrocks, I. (2004) OWL-QL - a

language for deductive query answering on the Semantic

Web.

[10].Caballero, R., García-Ruiz, Y., Sáenz-Pérez, F. A

Theoretical Framework for the Declarative Debugging of

Datalog Programs.

[11].H. Gallaire, J. Minker (Eds.), Logic and Databases,

- Railway Reservation SystemÎncărcat dechithambaramani
- Data ModelingÎncărcat deSanjana Garg
- Arena Table LayoutÎncărcat deGrace Point
- mca304Încărcat dekola0123
- ch-14Încărcat deZareen
- Hotel Managementfinal Report(Print)Încărcat deBishyer Amit
- A Logical Temporal Relational Data ModelÎncărcat deIJCSI Editor
- RDBMS.IntroductionÎncărcat depallavip10
- Dbms IntroductionÎncărcat demyscribd1111
- dbms-handbook.docÎncărcat deLalith Kartikeya
- Course - Introduction to Teradata DatabaseÎncărcat deAmarGaddam
- Lecture_6 Access Notes-1Încărcat deEli Justin Lim
- DBMS_COURSEFileÎncărcat deVivekananda Ganjigunta Narayana
- Teradata ArchitectureÎncărcat deDharshanaKrishnamurthy
- Deductive Database XujiaÎncărcat deMoutusi Paul
- cam sql lab file.docÎncărcat denancie3
- Computer Finals ReviewerÎncărcat deForkenstein
- DBMS-SyllabusÎncărcat deSangeetha Prakash
- Oracle Architecture Basic QuestionsÎncărcat deAmol Vishwas Gitapathi
- A Framework for Temporal Geographic Information - Gail Langran and Nicholas R. ChrismanÎncărcat deEdmilson Volpi
- RDBMsÎncărcat deFuad Abdosh
- Cs6302 Dbms NotesÎncărcat deshyam15287
- Lecture 8 - Entity Relationship Modelling - part II.pdfÎncărcat deChia Wei Han
- [IJCST-V4I5P28]: Thirunavukkarasu K, Dr. Manoj WadhwaÎncărcat deEighthSenseGroup
- 210080559-DMDW2Încărcat dehanmanth
- x.pdfÎncărcat deBobin baby
- laudon_mis12_tif_06Încărcat deKrizia Almiranez
- Universe-Designer-and-IDT-–-Compare-and-Contrast.pdfÎncărcat depandusudhir
- Mapping of XML Document and Relational Database (using Structural Queries)Încărcat deIJRASETPublications
- DBMS - Part 1 - Introduction.pptÎncărcat deINN Channel

- Thirapong Pipatpongsa_Statics of Loose Triangular Embankment Under Nadai's Sand Hill Analogy [2010]Încărcat dePrijeSamZnaoCitati
- Elementary Algebra Direct and Inverse ProportionÎncărcat deyones
- TG_MATH_G8_02Încărcat dePatricia Ara Grace Cortez
- systems of equation - business project lessonÎncărcat deapi-208358319
- Set-3 Complex VariablesÎncărcat deAkash Roy
- Reviewer - Differential CalculusÎncărcat deLorenz Ardiente
- prbookÎncărcat deFadly Nurullah
- Inequalities,algebra revision notes from A-level Maths TutorÎncărcat deA-level Maths Tutor
- Towards a Methodology for the Characterization of Teachers Didactic-mathematical KnowledgeÎncărcat deGreySi
- Mathematics Kssm Ylp Form 1 2019Încărcat deUchiha Madara
- Lee Christensen Rudd 1966Încărcat deNidha Kusuma
- Eliminition MethodÎncărcat deUsman Zafar
- Reno TrainingÎncărcat dematiasneri
- 19 Partial and SemiÎncărcat derohan48
- CMO 13, S. 2008, ANNEX III - Course Specification for the B.pdfÎncărcat deMike Posktova
- Computing the Distribution of the Product of Two Continuous Random VariablesÎncărcat delptuyen
- Math 8 Supplemental TextÎncărcat deGary
- verbal worksheetÎncărcat deapi-262479010
- Introduction to IBM SPSS Statistics 22Încărcat deMarcela Avitia
- EE203_01_Adm_jan13_18sÎncărcat deAsif Khan
- 5th grade algebra lessonÎncărcat deapi-338927224
- [Bernhard Riemann] Collected PapersÎncărcat demikservantes
- EulerÎncărcat deGiovanni Ferraro
- Math Problem SolvingÎncărcat dezspiro
- Quantitative Analysis Book-revision KitÎncărcat deTamba Junior
- 7. Drilling EconomicsÎncărcat deJim Bode
- The Relationship of Procedural and Declarative KnowledgeÎncărcat deMam Mamcom
- Simultaneous EquationÎncărcat desabbysamura
- 777_1Încărcat deAKHIL PASULA
- Derivative of Function of a FunctionÎncărcat deGurvir Sidhu

## Mult mai mult decât documente.

Descoperiți tot ce are Scribd de oferit, inclusiv cărți și cărți audio de la editori majori.

Anulați oricând.