Relational Algebra. Spring 2012 Instructor: Hassan Khosravi
|
|
- Tamsyn York
- 5 years ago
- Views:
Transcription
1 Relational Algebra Spring 2012 Instructor: Hassan Khosravi
2 Querying relational databases Lecture given by Dr. Widom on querying Relational Models 2.2
3 2.1 An Overview of Data Models What is a Data Model? Important Data Models The Relational Model in Brief The Semi-structured Model in Brief Other Data Models Comparison of Modeling Approaches 2.3
4 2.1.1 What is a Data Model? Data model is a notion for describing data or information. Real World Math Model: 1. Structure of the data (tuples) 2. Operations on the data queries to retrieve and modify information 3. Constraints on the data year has to be integer, name is string. Important data models The relational Model The semi-structured data model XML 2.4
5 Relational Model in Brief Title Year Length genre Gone with the wind Drama Star Wars SciFi Wayne s world comedy Relational model is based on tables Operations: query, modify Constraints: year is Integer between The structure may appear to resemble an array of structs in C where the column headers are the field names and each row represent the values of one struct in the array. Distinction in scales of relations Not normally implemented as main-memory structure Take into consideration to access relations on hard drive 2.5
6 The Semi-structured Model in Brief <Movies> <Movie title= Gone with the Wind > </Movie> <Year>1939</Year> <Length>231</Length> <Genre>drama</Genre> <Movie title= Star Wars > </Movie> <title= Wars > <Year>1977</Year> <Length>124</Length> <Genre>sciFi</Length> <Movie title= Wayne s World > </Movie> </Movies> <Year>1992</Year> <Length>95</Length> <Genre>comedy</Genre> Semi structure data resembles trees or graphs rather than tables or arrays. Operations usually involve following in the tree. 2.6 Find the movies with the comedy genre. Constraints often involve data types of values associated with a tag. Values associated with the length tag are integers
7 Comparison of Modeling Approaches Semi-structured models have more flexibility than relations. However, the relational model is still preferred in DBMS s. 1. Efficiency of access to data and efficiency of modifications to that data are more important than flexibility 2. ease of use is more important than flexibility. SQL enables the programmer to express their wishes at very high level. The strongly limited set of operations can be optimized to run very fast 2.7
8 Basics of the Relational model Title Year Length genre Gone with the wind Drama Star Wars SciFi Wayne s world comedy Attributes: columns of a relation are named attributes. Schema: the name of the relation and the set of attributes Movies(title, year, length, genre) Tuples: The rows of a relation, other than the header Domains: the value for each attribute must be atomic (can not be structure). Each attribute has a domain of values. 2.8
9 Equivalent Representations of a Relation Relations are sets of tuples not lists of tuples. The order of tuples does not matter. Attributes could be reordered too. Title Year Length genre Gone with the wind Drama Star Wars SciFi Wayne s world comedy Year Genre Title length 1977 SciFi Star Wars Comedy Wayne s World Drama Gone With the Wind 231 How many different ways can we present the given relation? 2.9
10 Relation Instances and Keys A set of tuples for a given relation is called an instance of that relation. It is expected for the instance of the relation to change over time. New movies are added to the table It is less common for the schema of a relation to change. It is hard to add a new value for all the current tuples if a new attribute is added to the schema. Keyes of relations Key constraints: A set of attributes form a key if we do not allow two tuples in a relation instance to have the same value. We indicate the attributes that form a key by underlining them Movies(title, year, length, genre) Key most be true for all possible instances of a relation not a specific instance. Genre is not a key What if our data does not have a key? Generate artificial ID. Student Number 2.10
11 Database Schema about Movies Movies( ) title: string; Year : integer, Length : integer, Genre : string, studioname : string, producerc# : integer Moviestar ( name : string, address : string, gender : char, birthdate : date ) MovieExec ( name: string, address : string cert# : integer networth : integer ) Studio ( ) name: string, address : string pressc# : integer StarsIn ( ) MovieTitle: string, Movieyear : integer Starname : string 2.11
12 Defining a Relation Schema in SQL Relations in SQL Data Types Simple Table Declarations Modifying Relation Schemas Default Values Declaring Keys Exercises for Section
13 2.3.1 Relations in SQL SQL also pronounced (sequel) is the principal language used to describe and manipulate relational database SQL makes a distinction between three kinds of relations Stored relations (tables): this relations are tables that exist in the database we can query and modify Views: are relations defined by a computation. They are not stored but constructed. We just query them (chapter 8) Temporary tables: are constructed by SQL language processor during optimization. These are not stored nor seen by the user 2.13
14 Data Types Char(n): a fixed-length string of up to n characters. Char(5) of foo is stored foo Varchar(n): a variable-length string of up to n characters Varchar(5) of foo is stored foo Bit(n), Varbit(n) fixed and variable string of upto n bits. Boolean: True False and although it would surprise George Boole Unknown Int or Integer: typical integer values Float or real: typical real values Decimal(6,2) could be Date and time: essentially char strings with constraints. 2.14
15 2.3.3 Simple Table Declarations CREATE TABLE Movie ( title VARCHAR(255), year INTEGER, length INTEGER, incolor CHAR(1), studioname CHAR(50), producerc# INTEGER, ); CREATE TABLE MOVIESTAR ( NAME CHAR(30), ADDRESS VARCHAR2(50), GENDER CHAR(6), BIRTHDATE DATE ); Movies( ) title: string; Year : integer, Length : integer, Genre : string, studioname : string, producerc# : integer Moviestar ( name : string, address : string, gender : char, birthdate : date ) 2.15
16 Modifying Relation Schemas We can delete a table R by the following SQL command Drop table R; We can modify a table by the command Alter Table MovieStar ADD phone CHAR(16); Alter Table MovieStar Drop birthdate; Defaults values To use the default character? As the default for an unknown gender. Earliest possible date for Unknown Birthdate. DATE Gender CHAR(1) DEFAULT?, Birthdate DATE DEFAULT DATE , ALTER TABLE MovieStar ADD phone CHAR (16) DEFAULT unlisted ; 2.16
17 2.3.6 Declaring Keys Two ways to declare keys in CRATE table statement Primary key can not be null Unique can be null Replace primary with unique in examples to get the example with unique CREATE TABLE MovieStar ( ); name CHAR (30) Primary Key, address VARCHAR (255), gender CHAR(1), birthdate DATE CREATE TABLE MovieStar ( ); name CHAR (30), address VARCHAR (255), gender CHAR(1), birthdate DATE PRIMARY KEY (name) 2.17
18 Example 2.7 The Relation Movie, whose key is the pair of attributes title and year must be declared like this CREATE TABLE Movies( title year length genre studiname producerc# PRIMARY KEY ); CHAR(100), INTEGER, INTEGER, CHAR(10), CHAR(30), INTEGER, (title,year) 2.18
19 Quick summary Lecture given by Dr. Widom on Relational Model definition 2.19
20 2.4 An Algebraic Query Language Why Do We Need a Special Query Language? What is an Algebra? Overview of Relational Algebra Set Operations on Relations Projection Selection Cartesian Product Natural Joins Theta-Joins Combining Operations to Form Queries Naming and Renaming Relationships Among Operations A Linear Notation for Algebraic Expressions Exercises for Section
21 Why Do We Need a Special Query Language? Why not just use C or java instead of introducing relational algebra? Relational algebra is useful because it is less powerful than C and Java. One of the only areas where non-turing-complete languages make sense. Relational algebra CANNOT determine whether the number of tuples are odd or even Being less powerful is helpful because Ease of programming Ease of compilation Ease of optimization 2.21
22 Projection The Projection operator applied to a relation R, produces a new relation with a subset of R s columns. Duplicate tuples are eliminated. Title Year Length Genre Studioname producerc# Star Wars SciFi Fox Galaxy Comedy DreamWorks Wayne s World Comedy Paramount Title,year,length (Movies) Title Year Length Star Wars Galaxy Quest Wayne s World genre (Movies) Genre SciFi Comedy 2.22
23 Selection and Projection Lecture given by Dr. Widom on selection and projection 2.23
24 2.4.6 Selection The selection operator applied to a relation R, produces a new relation with a subset of R s tuples. Title Year Length Genre Studioname producerc# Star Wars SciFi Fox Galaxy Comedy DreamWorks Wayne s World Comedy Paramount σ length >= 100 (Movie) Title Year Length Genre StudioName producerc# Star Wars SciFi Fox Galaxy Comedy DreamWorks
25 Example for Selection Set tuples in the relation movies that represent Fox Movies at least 100 minutes long. Title Year Length Genre Studioname producerc# Star Wars SciFi Fox Galaxy Comedy DreamWorks Wayne s World Comedy Paramount σ Length >= 100 AND studioname = Fox (Movies) Title Year Length Genre StudioName producerc# Star Wars SciFi Fox
26 2.4.7 Cartesian Product The Cartesian Product of two sets R and S is the set of pairs that can be formed by choosing the first element from R and the second from S. Relation R A B Relation S B C D Relation R X S A R.B S.B C D If R and S have some attribute in common, we need to invent new name for the identical attributes. 2.26
27 Cartesian Product Lecture given by Dr. Widom on duplicates, cross product 2.27
28 2.28
29 2.4.8 Natural Joins The Natural join of two sets R and S is the set of pairs that agree in whatever attributes are common to the schemas of R and S. Let A 1,A 2,, A n be attributes in both R and S. a tuple r from R and s from S are successfully paired if and only if r and s agree on A 1,A 2,, A n that can be formed by choosing the first element from R and the second from S. Relation R A B Relation S B C D Relation R S A B C D
30 Example for Natural Join A more complicated example for natural join Relation U A B C Relation V B C D Result U V A B C D
31 Lecture given by Dr. Widom on Natural Join 2.31
32 2.32
33 2.33
34 Theta-Joins It is sometimes desirable to pair tuples on other conditions except all the common attributes being equal. The notation for a theta-join of relation R and S based on condition C is R C S The result is constructed as follows: Take product of R and S Select tuples that satisfy C U A < D V Relation U A B C Relation V B C D A U.B U.C V.B V.C D
35 Example on Theta-Joins U and V that has more complex condition : We require for successful pairing not only that the A component of U-tuple be less than D component of the V-tuple, but that the two tuples disagree on their respective B components Relation U A B C Relation V B C D U A < D AND U.B <> V.B V A U.B U.C V.B V.C D
36 Combining Operations to Form Queries Example: What are the titles and years of movies made by Fox that are at least 100 minutes long Title,year σ length >=100 σ StudioName = Fox Movies Movies Title,year (σ length >=100 (Movies) σ StudioName = Fox (Movies) Title,year (σ length >=100 AND StudioName = Fox (Movies) 2.36
37 Relational algebra Algebra in general consists of operators and atomic operands Algebra of arithmetic operands are variables and constants and operators are (+, -, *, /). Any algebra allows us to build expressions by applying an operator to operands and other expressions. (x+y)/z Name Address Gender Birthdate Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Mark hamill 456 Oak road., Brentwood M 8/8/88 Relation R Name Address Gender Birthdate Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Harrison Ford 789 Palm Dr., Beverly Hills M 7/7/77 Relation S 2.37
38 Operations of relational algebra Union (R S): the set of elements that are in R, or S or both. Appears only once in the union. Relation R Name Address Gender Birthdate Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Mark hamill 456 Oak road., Brentwood M 8/8/88 Name Address Gender Birthdate Relation S Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Harrison Ford 789 Palm Dr., Beverly Hills M 7/7/77 Name Address Gender Birthdate Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Mark Hamill 456 oak Rd., Brentwood M 8/8/88 Harrison Ford 789 Palm Dr., Beverly Hills M 7/7/
39 Operations of relational algebra Intersection (R S): the set of elements that are in both R and S. Appears only once in the intersection. Relation R Name Address Gender Birthdate Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Mark hamill 456 Oak road., Brentwood M 8/8/88 Name Address Gender Birthdate Relation S Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Harrison Ford 789 Palm Dr., Beverly Hills M 7/7/77 Name Address Gender Birthdate Carrie Fisher 123 Maple st., Hollywood F 9/9/
40 Operations of relational algebra The Difference (R-S): the set of elements that are in R and not in S. Appears only once in the difference. Relation R Name Address Gender Birthdate Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Mark hamill 456 Oak road., Brentwood M 8/8/88 Name Address Gender Birthdate Relation S Carrie Fisher 123 Maple st., Hollywood F 9/9/99 Harrison Ford 789 Palm Dr., Beverly Hills M 7/7/77 Name Address Gender Birthdate Mark Hamill 456 oak Rd., Brentwood M 8/8/
41 Lecture given by Dr. Widom on union, difference, intersection 2.41
42 2.42
43 Naming and Renaming Operator to explicitly rename attributes in relations. PS(A1,A2,, An ) (R) results in a relation S that has exactly the same tuples as R but the attributes names are A 1,A 2,, A n starting from the left most attribute. Relation R A B Relation S B C D R X ρ s (X,C,D) (S) A B X C D
44 Lecture given by Dr. Widom on Renaming 2.44
45 Relationships Among Operations Intersection can be expressed as difference. R S = R (R S) See video Theta join can be expressed by product and selection R C S= (R S) C Natural join can be rewritten by product, selection, projection Example Result U V = A,U.B, U.C, D ( U.B=V.B AND U.C=V.B (U V)) Relation U A B C Relation V B C D These are the only redundancies ( union, difference, selection, projection, product, renaming) form an independent set Result U V A B C D
46 2.5 Constraints on Relations Relational Algebra as a Constraint Language Referential Integrity Constraints Key Constraints Additional Constraint Examples Exercises for Section Summary of Chapter References for Chapter
47 Referential Integrity Constraints Referential Integrity Constraints A value appearing in one context also appears in another, related context StarsIn(movietitle, movieyear,starname) Movie(title,year,length,studioName, producerc#) movietitle, movieyear (StarsIn) title,year (Movies) Movie(title,year,length,genre,studioName, producerc#) MovieExec(name,address,cert#,netWorth) producerc# (Movies) cert# (MocvieExec) 2.47
48 Key Constraints Recall that name is the key for relation MovieStar(name,address,gender,birthdate) The requirement can be expressed by the algebraic expression σ MS1.name = MS2.name AND MS1.address MS2.address (MS1 x MS2) = MS1 in the product MS1 x MS2 is shorthand for the remaining ρ MS1(name,address,gender,birthdate) (MovieStar) 2.48
49 Example 2.24 The only legal value for Gender attribute is F and M. We can express the gender attribute of MovieStar alegrabically by: σ Mgender F AND gender M (MovieStar) = 2.49
50 Example 2.25 If one must have networth of at least $100,000,000 to be president of movie studio. FROM MovieExec(name,address,cert#,networth) Studio(name,address, presc#) First we have to perform theta-join on this two relations. σ networth < (Studio presc# = cert# MovieExec) = Second way TpressC# (Studio) cert# (σ networth < (MovieExec)) Which one is more efficient? 2.50
51 Summary of Relational Algebra Lecture given by Dr. Widom on Relational Model 2.51
Programming and Database Fundamentals for Data Scientists
Programming and Database Fundamentals for Data Scientists Database Fundamentals Varun Chandola School of Engineering and Applied Sciences State University of New York at Buffalo Buffalo, NY, USA chandola@buffalo.edu
More informationRelational Model, Key Constraints
Relational Model, Key Constraints PDBM 6.1 Dr. Chris Mayfield Department of Computer Science James Madison University Jan 23, 2019 What is a data model? Notation for describing data or information Structure
More informationInformation Systems for Engineers. Exercise 10. ETH Zurich, Fall Semester Hand-out Due
Information Systems for Engineers Exercise 10 ETH Zurich, Fall Semester 2017 Hand-out 08.12.2017 Due 15.12.2017 1. (Exercise 8.1.1 in [1]) Movies(title, year, length, genre, studioname, producercertnumber)
More informationSQL queries II. Set operations and joins
SQL queries II Set operations and joins 1. Restrictions on aggregation functions 2. Nulls in aggregates 3. Duplicate elimination in aggregates REFRESHER 1. Restriction on SELECT with aggregation If any
More informationHigh-Level Database Models. Spring 2011 Instructor: Hassan Khosravi
High-Level Database Models Spring 2011 Instructor: Hassan Khosravi Database Modeling and implemnation process Ideas High-Level Design Relational Database Schema Relational DBMS 4.2 The Entity/Relationship
More informationSet Operations, Union
Set Operations, Union The common set operations, union, intersection, and difference, are available in SQL. The relation operands must be compatible in the sense that they have the same attributes (same
More informationNiklas Fors The Relational Data Model 1 / 17
The Relational Data Model From Entity Sets to Relations From Relationships to Relations Combining Relations Weak Entity Sets Relationships With Attributes Subclasses Niklas Fors (niklas.fors@cs.lth.se)
More informationDatabase Systems. Basics of the Relational Data Model
Database Systems Relational Design Theory Jens Otten University of Oslo Jens Otten (UiO) Database Systems Relational Design Theory INF3100 Spring 18 1 / 30 Basics of the Relational Data Model title year
More informationDatabase Modifications and Transactions
Database Modifications and Transactions FCDB 6.5 6.6 Dr. Chris Mayfield Department of Computer Science James Madison University Jan 31, 2018 pgadmin from home (the easy way) 1. Connect to JMU s network
More informationAC61/AT61 DATABASE MANAGEMENT SYSTEMS DEC 2013
Q.2 a. Define the following terms giving examples for each of them: Entity, attribute, role and relationship between the entities b. Describe any four main functions of a database administrator. c. What
More informationData Definition Language (DDL), Views and Indexes Instructor: Shel Finkelstein
Data Definition Language (DDL), Views and Indexes Instructor: Shel Finkelstein Reference: A First Course in Database Systems, 3 rd edition, Chapter 2.3 and 8.1-8.4 Important Notices Reminder: Midterm is
More informationInformation Systems Engineering. SQL Structured Query Language DML Data Manipulation (sub)language
Information Systems Engineering SQL Structured Query Language DML Data Manipulation (sub)language 1 DML SQL subset for data manipulation (DML) includes four main operations SELECT - used for querying a
More informationDatabases - Relations in Databases. (N Spadaccini 2010) Relations in Databases 1 / 16
Databases - Relations in Databases (N Spadaccini 2010) Relations in Databases 1 / 16 Re-capping - data model A data model is a precise, conceptual description of the data stored in a database. The relational
More informationRelational Model. CSE462 Database Concepts. Demian Lessa. Department of Computer Science and Engineering State University of New York, Buffalo
Relational Model CSE462 Database Concepts Demian Lessa Department of Computer Science and Engineering State University of New York, Buffalo January 21 24, 2011 Next... 1 Relational Model Lessa Relational
More information1. Given the name of a movie studio, find the net worth of its president.
1. Given the name of a movie studio, find the net worth of its president. CREATE FUNCTION GetNetWorth( studio VARCHAR(30) ) RETURNS DECIMAL(9,3) DECLARE worth DECIMAL(9,3); SELECT networth INTO worth FROM
More informationJoins, NULL, and Aggregation
Joins, NULL, and Aggregation FCDB 6.3 6.4 Dr. Chris Mayfield Department of Computer Science James Madison University Jan 29, 2018 Announcements 1. Your proposal is due Friday in class Each group brings
More informationIntroduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 2: Relations and SQL. September 5, Lecturer: Rasmus Pagh
Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 2: Relations and SQL September 5, 2005 Lecturer: Rasmus Pagh Today s lecture What, exactly, is the relational data model? What are
More informationMidterm 1 157A Fall /22
Midterm 1 157A Fall 2012 10/22 Class-id Name Part III Describe your contribution in the team project before mid night today. Part I Questions and Answers (10 pts EACH) 1. (DB3) Please write SQL for (a)
More informationThe Relational Model of Data (ii)
ICS 321 Fall 2013 The Relational Model of Data (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1 Defining Relational Schema in SQL Two aspects: Data
More informationInformation Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language
Information Systems Engineering SQL Structured Query Language DDL Data Definition (sub)language 1 SQL Standard Language for the Definition, Querying and Manipulation of Relational Databases on DBMSs Its
More informationDatabase Systems Architecture. Stijn Vansummeren
Database Systems Architecture Stijn Vansummeren 1 General Course Information Objective: To obtain insight into the internal operation and implementation of systems designed to manage and process large
More informationDatabases-1 Lecture-01. Introduction, Relational Algebra
Databases-1 Lecture-01 Introduction, Relational Algebra Information, 2018 Spring About me: Hajas Csilla, Mathematician, PhD, Senior lecturer, Dept. of Information Systems, Eötvös Loránd University of Budapest
More informationAsst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa
ICS 321 Spring 2011 Constraints, Triggers, Views & Indexes Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 04/04/2011 Lipyeow Lim -- University of Hawaii
More informationOptimization of logical query plans Eliminating redundant joins
Optimization of logical query plans Eliminating redundant joins 66 Optimization of logical query plans Query Compiler Execution Engine SQL Translation Logical query plan "Intermediate code" Logical plan
More informationRelational Database: The Relational Data Model; Operations on Database Relations
Relational Database: The Relational Data Model; Operations on Database Relations Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Overview
More informationRelational Algebra. Study Chapter Comp 521 Files and Databases Fall
Relational Algebra Study Chapter 4.1-4.2 Comp 521 Files and Databases Fall 2010 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model
More informationDatabase Technology Introduction. Heiko Paulheim
Database Technology Introduction Outline The Need for Databases Data Models Relational Databases Database Design Storage Manager Query Processing Transaction Manager Introduction to the Relational Model
More information5.2 E xtended Operators of R elational Algebra
5.2. EXTENDED OPERATORS OF RELATIONAL ALG EBRA 213 i)
More informationChapter 2: Intro to Relational Model
Non è possibile visualizzare l'immagine. Chapter 2: Intro to Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Example of a Relation attributes (or columns)
More informationRelational Query Languages: Relational Algebra. Juliana Freire
Relational Query Languages: Relational Algebra Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful QLs: Simple
More informationSQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas
SQL SQL Functionality stands for Structured Query Language sometimes pronounced sequel a very-high-level (declarative) language user specifies what is wanted, not how to find it number of standards original
More informationDatabase Systems CSE 303. Lecture 02
Database Systems CSE 303 Lecture 02 2016 Structure Query Language (SQL) 1 Today s Outline (mainly from chapter 2) SQL introduction & Brief History Relational Model Data in SQL Basic Schema definition Keys
More informationDatabase Systems CSE 303. Lecture 02
Database Systems CSE 303 Lecture 02 2016 Structure Query Language (SQL) Today s Outline (mainly from chapter 2) SQL introduction & Brief History Relational Model Data in SQL Basic Schema definition Keys
More informationChapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 4 Basic SQL Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries
More informationRelational Databases
Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 49 Plan of the course 1 Relational databases 2 Relational database design 3 Conceptual database design 4
More informationRelational Algebra and SQL. Basic Operations Algebra of Bags
Relational Algebra and SQL Basic Operations Algebra of Bags 1 What is an Algebra Mathematical system consisting of: Operands --- variables or values from which new values can be constructed. Operators
More informationRelational Algebra. Lecture 4A Kathleen Durant Northeastern University
Relational Algebra Lecture 4A Kathleen Durant Northeastern University 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple,
More informationCMP-3440 Database Systems
CMP-3440 Database Systems Relational DB Languages Relational Algebra, Calculus, SQL Lecture 05 zain 1 Introduction Relational algebra & relational calculus are formal languages associated with the relational
More informationConcepts from
1 Concepts from 3.1-3.2 Functional dependencies Keys & superkeys of a relation Reasoning about FDs Closure of a set of attributes Closure of a set of FDs Minimal basis for a set of FDs 2 Plan How can we
More informationAlgebraic laws extensions to relational algebra
Today: Query optimization. Algebraic laws extensions to relational algebra for select-distinct, grouping. Soon: Estimating costs. Algorithms for computing joins, other operations. 1 Query Optimization
More informationDatabases 1. Daniel POP
Databases 1 Daniel POP Week 4 Agenda The Relational Model 1. Origins and history 2. Key concepts 3. Relational integrity 4. Relational algebra 5. 12+1 Codd rules for a relational DBMSes 7. SQL implementation
More informationInstructor: Amol Deshpande
Instructor: Amol Deshpande amol@cs.umd.edu Data Models Conceptual representa8on of the data Data Retrieval How to ask ques8ons of the database How to answer those ques8ons Data Storage How/where to store
More informationChapter 2 The relational Model of data. Relational model introduction
Chapter 2 The relational Model of data Relational model introduction 1 Contents What is a data model? Basics of the relational model Next : How to define? How to query? Constraints on relations 2 What
More informationRelational Query Languages. Preliminaries. Formal Relational Query Languages. Example Schema, with table contents. Relational Algebra
Note: Slides are posted on the class website, protected by a password written on the board Reading: see class home page www.cs.umb.edu/cs630. Relational Algebra CS430/630 Lecture 2 Relational Query Languages
More informationOutline. Textbook Chapter 6. Note 1. CSIE30600/CSIEB0290 Database Systems Basic SQL 2
Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries in SQL INSERT, DELETE, and UPDATE Statements in SQL Additional Features of SQL Textbook Chapter 6 CSIE30600/CSIEB0290
More informationChapter 3: Introduction to SQL. Chapter 3: Introduction to SQL
Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of The SQL Query Language Data Definition Basic Query
More informationSQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210
SQL: Concepts Todd Bacastow IST 210: Organization of Data 2/17/2004 1 Design questions How many entities are there? What are the major entities? What are the attributes of each entity? Is there a unique
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
CHAPTER 6 Basic SQL Slide 6-2 Chapter 6 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries in SQL INSERT, DELETE, and UPDATE Statements in SQL Additional Features
More informationExam II Computer Programming 420 Dr. St. John Lehman College City University of New York 20 November 2001
Exam II Computer Programming 420 Dr. St. John Lehman College City University of New York 20 November 2001 Exam Rules Show all your work. Your grade will be based on the work shown. The exam is closed book
More informationWHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints
SQL KEREM GURBEY WHAT IS SQL Database query language, which can also: Define structure of data Modify data Specify security constraints DATA DEFINITION Data-definition language (DDL) provides commands
More informationCSCB20 Week 3. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017
CSCB20 Week 3 Introduction to Database and Web Application Programming Anna Bretscher Winter 2017 This Week Intro to SQL and MySQL Mapping Relational Algebra to SQL queries We will focus on queries to
More informationCS143: Relational Model
CS143: Relational Model Book Chapters (4th) Chapters 1.3-5, 3.1, 4.11 (5th) Chapters 1.3-7, 2.1, 3.1-2, 4.1 (6th) Chapters 1.3-6, 2.105, 3.1-2, 4.5 Things to Learn Data model Relational model Database
More informationRelational Model and Relational Algebra A Short Review Class Notes - CS582-01
Relational Model and Relational Algebra A Short Review Class Notes - CS582-01 Tran Cao Son January 12, 2002 0.1 Basics The following definitions are from the book [1] Relational Model. Relations are tables
More informationCMPT 354 Views and Indexes. Spring 2012 Instructor: Hassan Khosravi
CMPT 354 Views and Indexes Spring 2012 Instructor: Hassan Khosravi Three level vision of a database 1.2 What are views Relations that are defined with a create table statement exist in the physical layer
More informationChapter 2 The relational Model of data. Relational algebra
Chapter 2 The relational Model of data Relational algebra 1 Contents What is a data model? Basics of the relational model How to define? How to query? Constraints on relations 2 An algebraic query language
More informationRelational Algebra. csc343, Introduction to Databases Diane Horton, Michelle Craig, and Sina Meraji Fall 2017
Relational Algebra csc343, Introduction to Databases Diane Horton, Michelle Craig, and Sina Meraji Fall 2017 Simplifications While learning relational algebra, we will assume: Relations are sets, so now
More informationCSIE30600 Database Systems Basic SQL 2. Outline
Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries in SQL INSERT, DELETE, and UPDATE Statements in SQL Additional Features of SQL CSIE30600 Database Systems
More informationDatabases. Jörg Endrullis. VU University Amsterdam
Databases Jörg Endrullis VU University Amsterdam The Relational Model Overview 1. Relational Model Concepts: Schema, State 2. Null Values 3. Constraints: General Remarks 4. Key Constraints 5. Foreign Key
More informationRelational Algebra. Note: Slides are posted on the class website, protected by a password written on the board
Note: Slides are posted on the class website, protected by a password written on the board Reading: see class home page www.cs.umb.edu/cs630. Relational Algebra CS430/630 Lecture 2 Slides based on Database
More informationRelational Model and Relational Algebra
Relational Model and Relational Algebra CMPSCI 445 Database Systems Fall 2008 Some slide content courtesy of Zack Ives, Ramakrishnan & Gehrke, Dan Suciu, Ullman & Widom Next lectures: Querying relational
More informationChapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement
Chapter 4 Basic SQL Basic SQL SQL language Considered one of the major reasons for the commercial success of relational databases SQL Structured Query Language Statements for data definitions, queries,
More information2.2.2.Relational Database concept
Foreign key:- is a field (or collection of fields) in one table that uniquely identifies a row of another table. In simpler words, the foreign key is defined in a second table, but it refers to the primary
More informationRelational Algebra. Algebra of Bags
Relational Algebra Basic Operations Algebra of Bags What is an Algebra Mathematical system consisting of: Operands --- variables or values from which new values can be constructed. Operators --- symbols
More informationBasic operators: selection, projection, cross product, union, difference,
CS145 Lecture Notes #6 Relational Algebra Steps in Building and Using a Database 1. Design schema 2. Create schema in DBMS 3. Load initial data 4. Repeat: execute queries and updates on the database Database
More informationChapter 3: Introduction to SQL
Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query
More informationDatabase System Concepts, 5th Ed.! Silberschatz, Korth and Sudarshan See for conditions on re-use "
Database System Concepts, 5th Ed.! Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use " Data Definition! Basic Query Structure! Set Operations! Aggregate Functions! Null Values!
More informationRelational Algebra. Relational Query Languages
Relational Algebra π CS 186 Fall 2002, Lecture 7 R & G, Chapter 4 By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect,
More informationMidterm Review. Winter Lecture 13
Midterm Review Winter 2006-2007 Lecture 13 Midterm Overview 3 hours, single sitting Topics: Relational model relations, keys, relational algebra expressions SQL DDL commands CREATE TABLE, CREATE VIEW Specifying
More informationRelational Algebra. Procedural language Six basic operators
Relational algebra Relational Algebra Procedural language Six basic operators select: σ project: union: set difference: Cartesian product: x rename: ρ The operators take one or two relations as inputs
More informationIntroduction to Database Design, fall 2011 IT University of Copenhagen. Normalization. Rasmus Pagh
Introduction to Database Design, fall 2011 IT University of Copenhagen Normalization Rasmus Pagh Based on KBL sections 6.1-6.8 (except p. 203 207m), 6.9 (until Multivalued dependencies ), 6.11, and 6.12.
More informationIan Kenny. November 28, 2017
Ian Kenny November 28, 2017 Introductory Databases Relational Algebra Introduction In this lecture we will cover Relational Algebra. Relational Algebra is the foundation upon which SQL is built and is
More informationSQL DATA DEFINITION LANGUAGE
SQL DATA DEFINITION LANGUAGE DATABASE SCHEMAS IN SQL SQL is primarily a query language, for getting information from a database. DML: Data Manipulation Language SFWR ENG 3DB3 FALL 2016 MICHAEL LIUT (LIUTM@MCMASTER.CA)
More informationNormalization. Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms
Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms Normalization Niklas Fors (niklas.fors@cs.lth.se) Normalization 1 / 45
More informationSQL. Lecture 4 SQL. Basic Structure. The select Clause. The select Clause (Cont.) The select Clause (Cont.) Basic Structure.
SL Lecture 4 SL Chapter 4 (Sections 4.1, 4.2, 4.3, 4.4, 4.5, 4., 4.8, 4.9, 4.11) Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Modification of the Database
More informationDatabase Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.
Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 5 Structured Query Language Hello and greetings. In the ongoing
More informationSQL DATA DEFINITION LANGUAGE
9/27/16 DATABASE SCHEMAS IN SQL SQL DATA DEFINITION LANGUAGE SQL is primarily a query language, for getting information from a database. SFWR ENG 3DB3 FALL 2016 But SQL also includes a data-definition
More informationSQL (Structured Query Language)
Lecture Note #4 COSC4820/5820 Database Systems Department of Computer Science University of Wyoming Byunggu Yu, 02/13/2001 SQL (Structured Query Language) 1. Schema Creation/Modification: DDL (Data Definition
More informationInformation Systems Engineering. Other Database Concepts
Information Systems Engineering Other Database Concepts 1 Views In a database it is possible to create virtual tables called views Views are not stored in the database They are defined and computed from
More informationBirkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6)
Birkbeck (University of London) BSc/FD EXAMINATION Department of Computer Science and Information Systems Database Management (COIY028H6) CREDIT VALUE: 15 credits Date of examination: Monday 9th June 2014
More informationChapter 3: Introduction to SQL
Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query
More informationCS145 Introduction. About CS145 Relational Model, Schemas, SQL Semistructured Model, XML
CS145 Introduction About CS145 Relational Model, Schemas, SQL Semistructured Model, XML 1 Content of CS145 Design of databases. E/R model, relational model, semistructured model, XML, UML, ODL. Database
More informationThe SQL data-definition language (DDL) allows defining :
Introduction to SQL Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query Structure Additional Basic Operations Set Operations Null Values Aggregate Functions Nested Subqueries
More informationRelational Algebra and SQL
Relational Algebra and SQL Computer Science E-66 Harvard University David G. Sullivan, Ph.D. Example Domain: a University We ll use relations from a university database. four relations that store info.
More informationRelational Algebra. [R&G] Chapter 4, Part A CS4320 1
Relational Algebra [R&G] Chapter 4, Part A CS4320 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful QLs:
More informationCSCI3030U Database Models
CSCI3030U Database Models CSCI3030U RELATIONAL MODEL SEMISTRUCTURED MODEL 1 Content Design of databases. relational model, semistructured model. Database programming. SQL, XPath, XQuery. Not DBMS implementation.
More informationTHE AUSTRALIAN NATIONAL UNIVERSITY. Mid-Semester Examination August 2006 RELATIONAL DATABASES (COMP2400)
THE AUSTRALIAN NATIONAL UNIVERSITY Mid-Semester Examination August 2006 RELATIONAL DATABASES (COMP2400) Reading Time: 10 minutes Writing Time: 1 hour Permitted Materials: One A4 sheet with notes on both
More informationCSEN 501 CSEN501 - Databases I
CSEN501 - Databases I Lecture 5: Structured Query Language (SQL) Prof. Dr. Slim slim.abdennadher@guc.edu.eg German University Cairo, Faculty of Media Engineering and Technology Structured Query Language:
More informationRelational Algebra BASIC OPERATIONS DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA
Relational Algebra BASIC OPERATIONS 1 What is an Algebra Mathematical system consisting of: Operands -- values from which new values can be constructed. Operators -- symbols denoting procedures that construct
More informationuser specifies what is wanted, not how to find it
SQL stands for Structured Query Language sometimes pronounced sequel a very-high-level (declarative) language user specifies what is wanted, not how to find it number of standards original ANSI SQL updated
More informationChapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Example of a Relation attributes (or columns) tuples (or rows) 2.2 Attribute Types The
More informationRelational Model, Relational Algebra, and SQL
Relational Model, Relational Algebra, and SQL August 29, 2007 1 Relational Model Data model. constraints. Set of conceptual tools for describing of data, data semantics, data relationships, and data integrity
More informationIntroduction to Data Management. Lecture #11 (Relational Algebra)
Introduction to Data Management Lecture #11 (Relational Algebra) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v HW and exams:
More information1 Relational Data Model
Prof. Dr.-Ing. Wolfgang Lehner INTELLIGENT DATABASE GROUP 1 Relational Data Model What is in the Lecture? 1. Database Usage Query Programming Design 2 Relational Model 3 The Relational Model The Relation
More informationChapter 3. The Relational Model. Database Systems p. 61/569
Chapter 3 The Relational Model Database Systems p. 61/569 Introduction The relational model was developed by E.F. Codd in the 1970s (he received the Turing award for it) One of the most widely-used data
More informationRelational Model & Algebra. Announcements (Thu. Aug. 27) Relational data model. CPS 116 Introduction to Database Systems
Relational Model & Algebra CPS 116 Introduction to Database Systems Announcements (Thu. Aug. 27) 2 Homework #1 will be assigned next Tuesday Office hours: see also course website Jun: LSRC D327 Tue. 1.5
More informationBasant Group of Institution
Basant Group of Institution Visual Basic 6.0 Objective Question Q.1 In the relational modes, cardinality is termed as: (A) Number of tuples. (B) Number of attributes. (C) Number of tables. (D) Number of
More informationMahathma Gandhi University
Mahathma Gandhi University BSc Computer science III Semester BCS 303 OBJECTIVE TYPE QUESTIONS Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed
More informationQQ Group
QQ Group: 617230453 1 Extended Relational-Algebra-Operations Generalized Projection Aggregate Functions Outer Join 2 Generalized Projection Extends the projection operation by allowing arithmetic functions
More informationSQL Overview. CSCE 315, Fall 2017 Project 1, Part 3. Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch
SQL Overview CSCE 315, Fall 2017 Project 1, Part 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch SQL Structured Query Language Database language used to manage and query relational
More informationSQL Data Definition and Data Manipulation Languages (DDL and DML)
.. Cal Poly CPE/CSC 365: Introduction to Database Systems Alexander Dekhtyar.. SQL Data Definition and Data Manipulation Languages (DDL and DML) Note: This handout instroduces both the ANSI SQL synatax
More information