information systems & semantic web university of koblenz landau, germany advanced data modeling...
TRANSCRIPT
![Page 1: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/1.jpg)
<is web> Information Systems & Semantic Web
University of Koblenz ▪ Landau, Germany
Advanced Data Modeling
Steffen Staabwith
Simon Schenk
![Page 2: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/2.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 2
Recursion
connected(StartPoint, EndPoint) :-
arc(StartPoint, EndPoint).
connected(StartPoint, EndPoint) :-
arc(StartPoint, NextPoint),
connected(NextPoint, EndPoint).
![Page 3: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/3.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 3
Recursion
StartPoint and EndPoint are connected
if
StartPoint and EndPoint are connected by an arc
or
there exists an intermediate point NextPoint such that
StartPoint and NextPoint are connected by an arc and
NextPoint and EndPoint are connected.
![Page 4: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/4.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 4
Integrity constraints
Each class has at least one lecturer:
x (class(x) →y lecturer(y, x)).
Each class has at most one lecturer:
x(class(x) → yz(lecturer(y, x) lecturer(z, x) → y=z).
![Page 5: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/5.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 5
Complex values
route(StartPoint, EndPoint, [StartPoint, EndPoint]) :-
arc(StartPoint, EndPoint).
route(StartPoint, EndPoint, [StartPoint | Route]) :-
arc(StartPoint, NextPoint), route(NextPoint, EndPoint, Route).
![Page 6: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/6.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 6
Problems
Combinations of following three features create problems
with defining semantics of deductive databases and
designing query answering algorithms for them:
Negation; Recursion; Complex values.
Restrictions may be required on the use of
(combinations of) these features.
![Page 7: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/7.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 7
SWI Prolog:
http://www.swi-prolog.org/
![Page 8: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/8.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 8
Soccer database
% EXTENSIONAL DATABASE
% Relation nextLeague describes the hierarchy of leagues in
% UK
nextLeague(league2, league1).
nextLeague(league1, championship).
nextLeage(championship, premier).
![Page 9: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/9.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 9
% the list of clubs
club(arsenal).
club(watford).
club(leedsU).
club(miltonKeynesDons).
% the list of leagues of clubs
league(arsenal, premier).
league(watford, championship).
league(leedsU, league1).
league(miltonKeynesDons, league2).
![Page 10: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/10.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 10
% the list of players and where they are playing
player(andy,arsenal).
player(wim,watford).
player(liam, leedsU).
player(mike, miltonKeynesDons).
![Page 11: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/11.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 11
% some players foul other players
foul(andy,wim).
foul(andy,bert).
foul(andy,chris).
foul(andy,dan).
foul(wim, andy).
foul(wim, dan).
![Page 12: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/12.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 12
Soccer database
% INTENSIONAL DATABASE
% Relation nextLeagues describes the order on leagues
% It is defined as the transitive closure of nextLeague
higherLeague(LowerLeague, HigherLeague) :-
nextLeague(LowerLeague, HigherLeague).
higherLeague(LowerLeague, HigherLeague) :-
nextLeague(LowerLeague, MiddleLeague),
higherLeague(MiddleLeague, HigherLeague).
![Page 13: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/13.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 13
% A higher-leagued club is a club who is in a higher league
higherLeaguedClub(Higher, Lower) :-
league(Higher, HigherLeague),
league(Lower, LowerLeague),
higherLeague(LowerLeague, HigherLeague).
![Page 14: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/14.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 14
% likes is a relation among players.
% (i) every player likes himself
like(Player, Player) :-
player(Player).
% (ii) every player likes all players in higher-ranked clubs
like(Lower, Higher) :-
player(Lower, LowerClub),
player(Higher, HigherClub),
higherRankedClub(HigherClub, LowerClub).
![Page 15: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/15.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 15
% (iii) a player likes a lower-ranked player when
% players of the lower-ranked club
% do not foul other players of his club
likes(Higher, Lower) :-
player(Higher, HigherClub),
lower(LowerClub),
higherRankedClub(HigherClub, LowerClub),
not hasPlayerWhoFoulsSomePlayerFrom(LowerClub, HigherClub).
![Page 16: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/16.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 16
% an auxiliary relation: hasPlayerWhoFoulsSomePlayerFrom
hasPlayerWhoFoulsSomePlayerFrom(Club1, Club2) :-
player(Player1, Club1),
player(Player2, Club2),
foul(Player1, Player2).
![Page 17: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/17.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 17
% INTEGRITY CONSTRAINTS
% every club has a league
8x(club(x) ! 9y league(x, y)).
% only premier league player may foul more than one player
8 p, c, z1, z2
(player(p,c) Æ foul(p, z1) Æ foul(p, z2)
! z1 = z2 Ç league(c, premier)).
![Page 18: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/18.jpg)
<is web> Information Systems & Semantic Web
University of Koblenz ▪ Landau, Germany
Relational Data Model
![Page 19: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/19.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 19
Overview
Relational data model; Tuples and relations; Schemas and instances; Named vs. unnamed perspective; Relational algebra;
![Page 20: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/20.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 20
Table
Player Birth Year
Andy 1980
Wim 1975
Liam 1985
Mike 1988
Bert 1971
![Page 21: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/21.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 21
Observations
The rows of the table contain pairs occurring in the relation player.
There are two columns, labeled respectively by “name” and “birth year”.
The values in each column belong to different domains of possible values.
![Page 22: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/22.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 22
How to specify a relation
1. specifying the names of the columns (also called fields or attributes);
2. specifying a domain of possible values for each column;
3. enumerate all tuples in the relation.
(1)–(2) refer to the schema of this relation, while (3) to an instance.
![Page 23: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/23.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 23
Domains and attributes
A set of domains (sets of values);
A set of corresponding domain names d1, d2, …
A set of attributes a1, a2, …
D1;D2
![Page 24: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/24.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 24
Relation Schema and Instances
Tuple: any finite sequence (v1, … , vn).
n is the arity of this tuple.
Relation schema:
r(a1:d1, …, an:dn)
where n ¸ 0, r is a relation name, a1, …, an are distinct attributes, d1, …, dn are domain names.
Relation instance: finite set of tuples (v1, …, vn) of arity n such that vi 2 Di for all i.
![Page 25: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/25.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 25
Observation
1. The attributes in each column must be unique.
2. A relation is a set. Therefore, when we represent a relation by a table, the order of rows in the table does not matter.
Let us add to this:
3. The order of attributes does not matter.
![Page 26: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/26.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 26
New notation for tuples
A tuple is a set of pairs { (a1, v1), …, (an, vn) } denoted by { a1=v1, …, an=vn } ,
Let d1, …, dn be domain names and be the corresponding domains.
The tuple conforms to a relation schema r(a1:d1, …, an:dn) if vi 2 Di for all i.
D1; : : : ;Dn
![Page 27: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/27.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 27
Relational data are structured
Note that in the relational data model tuples stored in a table are structured:
all tuples conform to the same relation schema; the values in the same column belong to the same domain.
Untyped perspective: there is a single domain, so the second condition can be dropped.
![Page 28: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/28.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 28
Typed or untyped?
Consider the relation admire: admirer admired
wim andy
mike wim
liam andy
liam arsenal
![Page 29: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/29.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 29
Database schema and instance
Relational database schema: a collection of relation schemas with distinct relation names.
Relational database instance conforming to a relational database schema S: a mapping I from the relation names of S to relation
instances such that • for every relation schema r(a1:d1, … , an:dn) in S
the relation instance I(r) conforms to this relation schema.
![Page 30: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/30.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 30
Unnamed perspective
No attributes
a tuple is simply a sequence (v_1, … , v_n) of values.
The components of tuples can therefore be identified by their position in the tuple.
![Page 31: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/31.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 31
From Unnamed to Named Perspective
Introduce a collection of attributes #1,#2, …,
identify tuple (v1, … , vn) with the tuple { #1 = v1, … ,#n = vn }.
Likewise, identify relation schema r(d1, … , dn) with r(#1:d1, … ,#n:dn).
![Page 32: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/32.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 32
Relational Algebra and SQL
1. Can define new relations from existing ones;
2. Uses a collection of operations on relations to do so.
![Page 33: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/33.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 33
Constant
{ (v11, … , v1n),
…..
(vk1, … , vkn) }
![Page 34: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/34.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 34
Union
R1 [ R2 =
{(c1, … , ck) | (c1, … , ck) 2 R1 or
(c1, … , ck) 2 R2 }
![Page 35: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/35.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 35
Set difference
R_1 - R2 =
{(c1, … , ck) | (c1, … , ck) 2 R1 and
(c1, … , ck) 2 R2 }
![Page 36: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/36.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 36
Cartesian product
R1 £ R2 =
{(c1, … , ck, d1, … , dm) |
(c1, … , ck) 2 R1 and
(d1, … , dm) 2 R2 }.
![Page 37: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/37.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 37
Projection
Let now R be a relation of arity k and i1, … , im be numbers in {1, … , k}.
¼i1, … ,im
(R) = {(ci1, … , cim
) | (c1, … , ck) 2 R }.
We say that ¼i1, … ,im
(R) is obtained from R
by projection (on arguments i1, … , im).
![Page 38: Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in](https://reader035.vdocuments.net/reader035/viewer/2022062417/5519f23c5503464c588b46f7/html5/thumbnails/38.jpg)
<is web>
ISWeb - Information Systems & Semantic Web
Steffen [email protected] 38
Selection
Assume formulas on domains with “variables” #1, #2, ….
For example, #1 = #2.
¾F (R) = {(c1, …, ck) |
(c1, …, ck) 2 R and
F holds on (c1, …, ck)}.