Announcements. CSCI 334: Principles of Programming Languages. Exam Study Session: Monday, May pm TBL 202. Lecture 22: Domain Specific Languages

Similar documents
Announcements. CSCI 334: Principles of Programming Languages. Thanks! Lecture 23: Exam Review. Announcements. Announcements

Introduction to Data Management. Lecture #11 (Relational Algebra)

2.2.2.Relational Database concept

Relational Model and Relational Algebra

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 1. Textbook. Practicalities: assessment. Aims and objectives of the course

Relational Database: The Relational Data Model; Operations on Database Relations

Relational Model and Relational Algebra A Short Review Class Notes - CS582-01

CMP-3440 Database Systems

CS61A Lecture 38. Robert Huang UC Berkeley April 17, 2013

Announcements. Relational Model & Algebra. Example. Relational data model. Example. Schema versus instance. Lecture notes

Database Technology Introduction. Heiko Paulheim

CS143: Relational Model

Relational Algebra. Lecture 4A Kathleen Durant Northeastern University

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

Relational Model & Algebra. Announcements (Thu. Aug. 27) Relational data model. CPS 116 Introduction to Database Systems

RELATIONAL ALGEBRA. CS 564- Fall ACKs: Dan Suciu, Jignesh Patel, AnHai Doan

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until

THE HALTING PROBLEM. Joshua Eckroth Chautauqua Nov

6. Relational Algebra (Part II)

Relational Algebra. [R&G] Chapter 4, Part A CS4320 1

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler

Relational Algebra. Study Chapter Comp 521 Files and Databases Fall

Relational Model 2: Relational Algebra

Ian Kenny. November 28, 2017

Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations Zvi M. Kedem 1

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

Chapter 12. Computability Mechanizing Reasoning

CS 377 Database Systems

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra

v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and manipulating data

Web Science & Technologies University of Koblenz Landau, Germany. Relational Data Model

Chapter 3. The Relational Model. Database Systems p. 61/569

2.3 Algorithms Using Map-Reduce

Notes on Turing s Theorem and Computability

Chapter 6 Part I The Relational Algebra and Calculus

Discrete Mathematics Lecture 4. Harper Langston New York University

Informationslogistik Unit 5: Data Integrity & Functional Dependency

Relational Algebra 1

Relational Algebra. Relational Query Languages

Relational Algebra. Spring 2012 Instructor: Hassan Khosravi

System Correctness. EEC 421/521: Software Engineering. System Correctness. The Problem at Hand. A system is correct when it meets its requirements

Chapter 1: Introduction

Relational Algebra 1. Week 4

Course notes for Data Compression - 2 Kolmogorov complexity Fall 2005

Lecture #8 (Still More Relational Theory...!)

Databases Lectures 1 and 2

Relational Model and Algebra. Introduction to Databases CompSci 316 Fall 2018

Relational Model & Algebra. Announcements (Tue. Sep. 3) Relational data model. CompSci 316 Introduction to Database Systems

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

Chapter 6 The Relational Algebra and Calculus

1 Relational Data Model

Chapter 2: Intro to Relational Model

Relational Query Languages: Relational Algebra. Juliana Freire

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra

Uncertainty in Databases. Lecture 2: Essential Database Foundations

Chapter 2: Intro to Relational Model

Chapter 6 Formal Relational Query Languages

Computation Club: Gödel s theorem

Mahathma Gandhi University

Basant Group of Institution

Relational Query Languages

Introduction to Data Management. Lecture #11 (Relational Languages I)

Informatics 1: Data & Analysis

Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations Zvi M. Kedem 1

The Data Organization

CS2300: File Structures and Introduction to Database Systems

Lecture 16. The Relational Model

Database Management Systems. Chapter 4. Relational Algebra. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler

Relational Algebra Homework 0 Due Tonight, 5pm! R & G, Chapter 4 Room Swap for Tuesday Discussion Section Homework 1 will be posted Tomorrow

Lecture 5: The Halting Problem. Michael Beeson

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

CMPT 354: Database System I. Lecture 5. Relational Algebra

14.1 Encoding for different models of computation

Relational Algebra for sets Introduction to relational algebra for bags

CS411 Database Systems. 04: Relational Algebra Ch 2.4, 5.1

CIS 330: Applied Database Systems. ER to Relational Relational Algebra

6.830 Lecture 2 9/11/2017 Relational Data Model (PS1 Out)

Relational Databases

CAS CS 460/660 Introduction to Database Systems. Relational Algebra 1.1

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

CSE 105 THEORY OF COMPUTATION

Database Systems External Sorting and Query Optimization. A.R. Hurson 323 CS Building

CSE-6490B Final Exam

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Relational Databases Fall 2017 Lecture 1

Informationslogistik Unit 4: The Relational Algebra

Faloutsos - Pavlo CMU SCS /615

Relational Databases. Relational Databases. Extended Functional view of Information Manager. e.g. Schema & Example instance of student Relation

Overview. Carnegie Mellon Univ. School of Computer Science /615 - DB Applications. Concepts - reminder. History

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Introduction to Relational Database Systems Fall 2016 Lecture 1

; Spring 2008 Prof. Sang-goo Lee (14:30pm: Mon & Wed: Room ) ADVANCED DATABASES

QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS

Introduction to Computer Science

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

EECS 647: Introduction to Database Systems

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out end of week start early!

Relational Model: History

Transcription:

Announcements CSCI 334: Principles of Programming Languages Lecture 22: Domain Specific Languages Exam Study Session: Monday, May 14 2-4pm TBL 202 Instructor: Dan Barowy Exercise Domain Specific Languages Construct the a knowledge base containing the following facts: Giants eat people. Giants eat bunnies. Bunnies eat grass. People eat bunnies. People eat people. Those who are eaten by others hate those others. Monsters love those who hate themselves. Then supply a query that can answer: Who do monsters love? A domain specific language (DSL) is a language designed to solve a small set of tasks. DSLs frequently sacrifice expressiveness in favor of ease of use.

Examples Examples SQL, used to manipulate tabular data HTML, used to represent web documents Verilog, a hardware description language PCRE, a string matching language based on regular expressions Make, used to describe software build dependencies XPath, used to query XML Postscript, used to describe printed documents LaTeX, used to cause undergraduates great anguish SQL cannot be used to perform arbitrary calculations; until recently (1999), it could not compute reachability queries. E.g., the transitive closure of city y is reachable from city x via direct flight computes the set of all cities reachable from city x. Why? Presumably the designers intended to disallow expensive queries. In fact, SQL is not Turing Complete. All SQL programs halt, by design. Examples Completeness Postscript is Turing Complete. But writing arbitrary programs is a huge pain. Commands are in Reverse Polish Notation ( operands first ) The stack must be explicitly maintained No user-defined types, etc. Great for offloading complex print jobs to a printer, though! Laser printers often ship with highly optimized Postscript interpreters (Raster Image Processor) A formal system is a logical system for generating formulas. A formal system is complete with respect to a property if all formulas having that property can be derived using the rules (axioms) of the system.

Soundness Incompleteness Theorem Kurt Gödel proved that mathematics (i.e., A formal system is sound with respect to a property if all derivable formulas are true. mathematical logic) cannot be both sound and complete wrt provability. Either: you can define a formal system in which you can derive all the true mathematical statements, but which also admits false statements (inconsistent), or you can define a formal system in which all statements are true, but in which you cannot derive all the true mathematical statements (incomplete). https://youtu.be/o4ndidcdsgc SQL SQL is a DSL for querying data, invented by E. F. Codd in 1970. SQL limits itself to only certain kinds of queries. All of those queries can be answered efficiently (and by implication, they terminate). The language is based on a theory of data and data queries called the relational algebra. The relational algebra lets users efficiently query data in a form that is largely independent of the organization of the data on disk. This was considered a major breakthrough when it was invented. For many practical reasons, SQL has diverged somewhat from the relational algebra. Relational Algebra The relational algebra is based on set theory. A relation R is a set of tuples. Remember that sets contain only unique elements. Also, the order of elements in a set does not matter. The members of a tuple are called attributes. Note that the order of attributes in a tuple does not matter. We often think of relations as tables. But since relations are really sets of tuples, the order of attributes and rows in a table does not matter. A schema is the set of all defined relations. A database is a collection of instances of relations for a given schema.

Relational Algebra: Closure Property Relational Algebra: Projection All operations in the relational algebra are closed, meaning that every operation on a relation yields a relation. Primitive operations: Projection Selection Rename Cartesian Product Complex operations: Join, etc. Projection selects columns of a relation. Π a1,, an (R) yields the relation R such that R is restricted on attributes a 1,,a n. For example, Π Name,DeptName() yields Π Name,DeptName() Relational Algebra: Selection Relational Algebra: Rename Selection selects rows of a relation. σ φ(r) yields the relation R such that R is restricted on the predicate φ. For example, σ EmpId > 3000() yields Rename renames an attribute in a relation. ρ a/b(r) yields the relation R such that attribute a is renamed to b in R. For example, ρ EmpId/Id() yields σ EmpId > 3000() ρ EmpId/Id()

Relational Algebra: Cartesian Product Cartesian product pairs every tuple in relation R with a tuple in relation S. R S yields the relation T = { (r1,,rn,s1,,sn) (r1,,rn) R, (s1,,sn) S } Note that this is not quite the set theory Cartesian product because tuples are flattened. For example, Dept yields Dept Dept Relational Algebra: Natural Join A number of useful operations called joins can be defined in terms of the primitive projection, selection, rename, and Cartesian product operations we just defined. Natural join pairs every tuple in relation R with a tuple in relation S where they agree on an attribute value. R is yields the relation T = { (r1,,rn,s1,,sn) (r1,,rn) R, (s1,,sn) S } where r i = s i for a given i. Dept DeptNameDept Optimizations Importance of SQL Because relational algebra abstracts queries from data representation, data can be organized on disk in whatever manner is the most efficient. Furthermore, the actual execution plan can be computed dynamically to take full advantage of hardware resources. For example, selection and projection both produce smaller relations than their inputs. Thus, if a query combines joins and selection/ projection, a query planner can reorder operations so that selection/ projection come first, reducing the number of tuples that must be computed in a join. This optimization is called predicate pushdown. Efficient database implementation is an active area of research (VLDB, SIGMOD, etc). SQL is one of the most important and successful languages ever invented. E.F., Codd won a Turing Award for his work on the relational algebra and relational database management systems. As of 2017, relational database systems alone were a $50 billion market.