Datalog Another formalism for expressing queries: - cleaner - closer to a “logic” notation - more convenient for analysis - equivalent in power to relational.

Slides:



Advertisements
Similar presentations
1 Datalog: Logic Instead of Algebra. 2 Datalog: Logic instead of Algebra Each relational-algebra operator can be mimicked by one or several Database Logic.
Advertisements

Storing Data: Disk Organization and I/O
Storing Data: Disks and Files
Databasteknik Databaser och bioinformatik Data structures and Indexing (II) Fang Wei-Kleiner.
Physical DataBase Design
Storing Data: Disks and Files: Chapter 9
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Storing Data: Disks and Files Chapter 7.
Advance Database System
Chapter 3 An Introduction to Relational Databases.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
Efficient Storage and Retrieval of Data
Murali Mani Overview of Storage and Indexing (based on slides from Wisconsin)
Embedded SQL Direct SQL is rarely used: usually, SQL is embedded in some application code. We need some method to reference SQL statements. But: there.
Introduction to Database Systems 1 Storing Data: Disks and Files Chapter 3 “Yea, from the table of my memory I’ll wipe away all trivial fond records.”
Introduction to Database Systems 1 The Storage Hierarchy and Magnetic Disks Storage Technology: Topic 1.
Layers of a DBMS Query optimization Execution engine Files and access methods Buffer management Disk space management Query Processor Query execution plan.
1 Lecture 7: Data structures for databases I Jose M. Peña
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Storing Data: Disks and Files Chapter 9.
Lecture 11: DMBS Internals
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Storing Data: Disks and Files Chapter 7.
Physical Storage Susan B. Davidson University of Pennsylvania CIS330 – Database Management Systems November 20, 2007.
Introduction to Database Systems 1 Storing Data: Disks and Files Chapter 3 “Yea, from the table of my memory I’ll wipe away all trivial fond records.”
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Storing Data: Disks and Files Chapter 7 “ Yea, from the table of my memory I ’ ll wipe away.
1 Storing Data: Disks and Files Chapter 9. 2 Disks and Files  DBMS stores information on (“hard”) disks.  This has major implications for DBMS design!
“Yea, from the table of my memory I’ll wipe away all trivial fond records.” -- Shakespeare, Hamlet.
Recursive query plans for Data Integration Oliver Michael By Rajesh Kanisetti.
Lecture #19 May 13 th, Agenda Trip Report End of constraints: triggers. Systems aspects of SQL – read chapter 8 in the book. Going under the lid!
ICS 321 Fall 2011 Overview of Storage & Indexing (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 11/9/20111Lipyeow.
Database Management Systems,Shri Prasad Sawant. 1 Storing Data: Disks and Files Unit 1 Mr.Prasad Sawant.
IDA / ADIT Databasteknik Databaser och bioinformatik Data structures and Indexing (I) Fang Wei-Kleiner.
Storage and Indexes Introduction to Databases Computer Science 557 Instructor: Joe Bockhorst University of Wisconsin - Milwaukee.
Datalog Inspired by the impedance mismatch in relational databases. Main expressive advantage: recursive queries. More convenient for analysis: papers.
Chapter Ten. Storage Categories Storage medium is required to store information/data Primary memory can be accessed by the CPU directly Fast, expensive.
Datalog –Another query language –cleaner – closer to a “logic” notation, prolog – more convenient for analysis – can express queries that are not expressible.
DMBS Internals I. What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently.
Layers of a DBMS Query optimization Execution engine Files and access methods Buffer management Disk space management Query Processor Query execution plan.
Database Systems Disk Management Concepts. WHY DO DISKS NEED MANAGING? logical information  physical representation bigger databases, larger records,
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Storing Data: Disks and Files Content based on Chapter 9 Database Management Systems, (3.
Lu Chaojun, SJTU 1 Extended Relational Algebra. Bag Semantics A relation (in SQL, at least) is really a bag (or multiset). –It may contain the same tuple.
Storage Systems CSE 598d, Spring 2007 OS Support for DB Management DB File System April 3, 2007 Mark Johnson.
ICS 321 Fall 2011 Algebraic and Logical Query Languages (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at.
DMBS Internals I February 24 th, What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the.
DMBS Internals I. What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently.
DMBS Architecture May 15 th, Generic Architecture Query compiler/optimizer Execution engine Index/record mgr. Buffer manager Storage manager storage.
1 Lecture 15: Data Storage, Recovery Monday, February 13, 2006.
Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Storing Data: Disks and Files Chapter 7 Jianping Fan Dept of Computer Science UNC-Charlotte.
What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently and safely. Provide.
1 Lecture 16: Data Storage Wednesday, November 6, 2006.
1 Storing Data: Disks and Files Chapter 9. 2 Objectives  Memory hierarchy in computer systems  Characteristics of disks and tapes  RAID storage systems.
The very Essentials of Disk and Buffer Management.
CS522 Advanced database Systems
CS 540 Database Management Systems
Module 11: File Structure
Datalog Rules / Programs / Negation Slides by Jeffrey D. Ullman
Database Management System
Lecture 16: Data Storage Wednesday, November 6, 2006.
Database Management Systems (CS 564)
Modifying the Database
End of XQuery DBMS Internals
Chapter 12: Query Processing
Lecture 11: DMBS Internals
Lecture 9: Data Storage and IO Models
Disk Storage, Basic File Structures, and Buffer Management
Lecture 9: Relational Algebra (continued), Datalog
Basics Storing Data on Disks and Files
Logic Based Query Languages
Datalog Inspired by the impedance mismatch in relational databases.
Files and access methods
Lecture 18: DMBS Overview and Data Storage
Lecture 15: Data Storage Tuesday, February 20, 2001.
Presentation transcript:

Datalog Another formalism for expressing queries: - cleaner - closer to a “logic” notation - more convenient for analysis - equivalent in power to relational algebra - will later allow us to consider queries with recursion

Predicates and Atoms - relations are represented by predicates - tuples are represented by atoms. Purchase( “joe”, “bob”, “Nike Town”, “Nike Air”, 2/2/98) - arithmetic atoms: X Z/2 - negated atoms: NOT Product(“Brooklyn Bridge”, $100, “Microsoft”)

Datalog Rules and Queries A datalog rule has the following form: head :- atom1, atom2, …., atom,… ExpensiveProduct(X) :- Product(X,Y,P) & P > $100 BritishProduct(X) :- Product(X,Y,P) & Company(P, “UK”, SP) P(X,Y) :- Between(X,Y,Z) & NOT Direct(X,Z)

The Meaning of Datalog Rules ExpensiveProduct(X) :- Product(X,Y,P) & P > $100 Consider every assignment from the variables in the body to the constants in the database. If each of the atoms in the body is made true by the assignment, then add the tuple for the head into the relation of the head.

Rule Safety Every variable that appears anywhere in the query must appear also in a relational, nonnegated atom in the query. Q(X,Y,Z) :- R1(X,Y) & X < Z not safe Q(X,Y,Z) :- R1(X,Y) & NOT R2(X,Y,Z) not safe

Composing Datalog Rules Extensional predicates: represent relations appearing in the database. Intentional predicates: defined by rules. These can be thought of as being views. Datalog rules may be composed in order to express more complex queries.

An Example Query Find employees participating in projects that don’t involve their department heads: EmpInvolve ( X, P, H) :- Project(P,X, S, E, B, D) & Employee( X, N ) & Department( N, H) DHInvolve ( X, P, H) :- Project( P, H, S, E, B, D) & Department( N, H) & Employee( P, N ) Answer (X) :- EmpInvolve(X, P, H) & NOT DHInvolve( X, P, H).

From Relational Algebra to Datalog We can translate any relational algebra operation to datalog: - projection - selection - union - intersection - join

Architecture of a DBMS Query optimization and execution Relational operators Files and access methods Buffer management Disk space management

The Memory Hierarchy Main Memory Disks Tapes Volatile limited address spaces expensive average access time: 5 microseconds 5-10 MB/S transmission rates 2-10 GB storage average time to access a block: msecs. Need to consider seek, rotation, transfer times. Keep records “close” to each other. 1.5 MB/S transfer rate 280 GB typical capacity Only sequential access Not for operational data

Disk Space Manager Task: manage the location of pages on disk (page = block) Provides commands for: allocating and deallocating a page on disk reading and writing pages. Why not use the operating system for this task? Portability Limited size of address space May need to span several disk devices.

Buffer Manager Manages buffer pool: the pool provides space for a limited number of pages from disk. Needs to decide on page replacement policy. Enables the higher levels of the DBMS to assume that the needed data is in main memory. Why not use the Operating System for the task?? - DBMS may be able to anticipate access patterns - Hence, may also be able to perform prefetching - DBMS needs the ability to force pages to disk.

Managing Files The abstraction used by the higher levels of the DBMS is of files. For example, a relation is stored in a file. A file will typically consist of many pages. Main issue: how to organize the records in a file? Approaches: heap files ordered files hashed files additional index structures.