Unit Relational Algebra 1 1. Relational Algebra 1. Unit 3.3

Like dokumenter
Databases 1. Extended Relational Algebra

Slope-Intercept Formula

Hvordan føre reiseregninger i Unit4 Business World Forfatter:

UNIVERSITY OF OSLO DEPARTMENT OF ECONOMICS

Trigonometric Substitution

Oppgave 1a Definer følgende begreper: Nøkkel, supernøkkel og funksjonell avhengighet.

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

EN Skriving for kommunikasjon og tenkning

Dynamic Programming Longest Common Subsequence. Class 27

Neural Network. Sensors Sorter

Information search for the research protocol in IIC/IID

Mathematics 114Q Integration Practice Problems SOLUTIONS. = 1 8 (x2 +5x) 8 + C. [u = x 2 +5x] = 1 11 (3 x)11 + C. [u =3 x] = 2 (7x + 9)3/2

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

UNIVERSITETET I OSLO

5 E Lesson: Solving Monohybrid Punnett Squares with Coding

Dagens tema: Eksempel Klisjéer (mønstre) Tommelfingerregler

Exercise 1: Phase Splitter DC Operation

Ole Isak Eira Masters student Arctic agriculture and environmental management. University of Tromsø Sami University College

Du må håndtere disse hendelsene ved å implementere funksjonene init(), changeh(), changev() og escape(), som beskrevet nedenfor.

Emneevaluering GEOV272 V17

Hvor mye praktisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen, 5 = mye)

HONSEL process monitoring

Eksamen ENG1002/1003 Engelsk fellesfag Elevar og privatistar/elever og privatister. Nynorsk/Bokmål

Gradient. Masahiro Yamamoto. last update on February 29, 2012 (1) (2) (3) (4) (5)

XML enabled database. support for XML in Microsoft SQL Server 2000 & Martin Malý

buildingsmart Norge seminar Gardermoen 2. september 2010 IFD sett i sammenheng med BIM og varedata

Han Ola of Han Per: A Norwegian-American Comic Strip/En Norsk-amerikansk tegneserie (Skrifter. Serie B, LXIX)

Endelig ikke-røyker for Kvinner! (Norwegian Edition)

Continuity. Subtopics

EMPIC MEDICAL. Etterutdanningskurs flyleger 21. april Lars (Lasse) Holm Prosjektleder Telefon: E-post:

Andrew Gendreau, Olga Rosenbaum, Anthony Taylor, Kenneth Wong, Karl Dusen

Perpetuum (im)mobile

Windlass Control Panel

Den som gjør godt, er av Gud (Multilingual Edition)

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

GYRO MED SYKKELHJUL. Forsøk å tippe og vri på hjulet. Hva kjenner du? Hvorfor oppfører hjulet seg slik, og hva er egentlig en gyro?

Gir vi de resterende 2 oppgavene til én prosess vil alle sitte å vente på de to potensielt tidskrevende prosessene.

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

Moving Objects. We need to move our objects in 3D space.

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

TEKSTER PH.D.-VEILEDERE FREMDRIFTSRAPPORTERING DISTRIBUSJONS-E-POST TIL ALLE AKTUELLE VEILEDERE:

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

Trådløsnett med. Wireless network. MacOSX 10.5 Leopard. with MacOSX 10.5 Leopard

Kneser hypergraphs. May 21th, CERMICS, Optimisation et Systèmes

Elektronisk innlevering/electronic solution for submission:

SERVICE BULLETINE

Prosjektet Digital kontaktinformasjon og fullmakter for virksomheter Digital contact information and mandates for entities

PSi Apollo. Technical Presentation

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

EXAM TTM4128 SERVICE AND RESOURCE MANAGEMENT EKSAM I TTM4128 TJENESTE- OG RESSURSADMINISTRASJON

Administrasjon av postnummersystemet i Norge Post code administration in Norway. Frode Wold, Norway Post Nordic Address Forum, Iceland 5-6.

Examination paper for (BI 2015) (Molekylærbiologi, laboratoriekurs)

GEOV219. Hvilket semester er du på? Hva er ditt kjønn? Er du...? Er du...? - Annet postbachelor phd

FYSMEK1110 Eksamensverksted 23. Mai :15-18:00 Oppgave 1 (maks. 45 minutt)

Hvordan 3 konsulenter tester et konserndatavarehus

Trådløsnett med Windows XP. Wireless network with Windows XP

matematikk s F4814A8B1B37D77C639B3 Matematikk S1 1 / 6

6350 Månedstabell / Month table Klasse / Class 1 Tax deduction table (tax to be withheld) 2012

Graphs similar to strongly regular graphs

Kartleggingsskjema / Survey

Guidance. CBEST, CSET, Middle Level Credential

Generalization of age-structured models in theory and practice

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

Physical origin of the Gouy phase shift by Simin Feng, Herbert G. Winful Opt. Lett. 26, (2001)

SVM and Complementary Slackness

FIRST LEGO League. Härnösand 2012

// Translation // KLART SVAR «Free-Range Employees»

KROPPEN LEDER STRØM. Sett en finger på hvert av kontaktpunktene på modellen. Da får du et lydsignal.

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

JBV DSB godkjenninger

Gol Statlige Mottak. Modul 7. Ekteskapsloven

Enkel og effektiv brukertesting. Ida Aalen LOAD september 2017

AvtaleGiro beskrivelse av feilmeldinger for oppdrag og transaksjoner kvitteringsliste L00202 levert i CSV fil

UNIVERSITETET I OSLO

Verifiable Secret-Sharing Schemes

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

HOW TO GET TO TØI By subway (T-bane) By tram By bus By car Fra flyplassen

Vedlegg 2 Dokumentasjon fra TVM leverandør

TUSEN TAKK! BUTIKKEN MIN! ...alt jeg ber om er.. Maren Finn dette og mer i. ... finn meg på nett! Grafiske lisenser.

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

MID-TERM EXAM TDT4258 MICROCONTROLLER SYSTEM DESIGN. Wednesday 3 th Mars Time:

Endringer i neste revisjon av EHF / Changes in the next revision of EHF 1. October 2015

TMA4329 Intro til vitensk. beregn. V2017

TEKSTER PH.D.-KANDIDATER FREMDRIFTSRAPPORTERING

TUSEN TAKK! BUTIKKEN MIN! ...alt jeg ber om er.. Maren Finn dette og mer i. ... finn meg på nett! Grafiske lisenser.

Smart High-Side Power Switch BTS730

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

INSTALLATION GUIDE FTR Cargo Rack Regular Ford Transit 130" Wheelbase ( Aluminum )

TUSEN TAKK! BUTIKKEN MIN! ...alt jeg ber om er.. Maren Finn dette og mer i. ... finn meg på nett! Grafiske lisenser.

STILLAS - STANDARD FORSLAG FRA SEF TIL NY STILLAS - STANDARD

1. Explain the language model, what are the weaknesses and strengths of this model?

UNIVERSITETET I OSLO ØKONOMISK INSTITUTT

INSTALLATION GUIDE FTR Cargo Rack Regular Ford Transit 130" Wheelbase ( Aluminum )

Uke 5. Magnus Li INF /

Compello Fakturagodkjenning Versjon 10 Software as a service. Tilgang til ny modulen Regnskapsføring

Skjema for spørsmål og svar angående: Skuddbeskyttende skjold Saksnr TED: 2014/S

Transkript:

Relational Algebra 1 Unit 3.3 Unit 3.3 - Relational Algebra 1 1

Relational Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics which underpin SQL operations. Operators in relational algebra are not necessarily the same as SQL operators, even if they have the same name. Unit 3.3 - Relational Algebra 1 2

Terminology Relation - a set of tuples. Tuple - a collection of attributes which describe some real world entity. Attribute - a real world role played by a named domain. Domain - a set of atomic values. Set - a mathematical definition for a collection of objects which contains no duplicates. Unit 3.3 - Relational Algebra 1 3

Operators - Write INSERT - provides a list of attribute values for a new tuple in a relation. This operator is the same as SQL. DELETE - provides a condition on the attributes of a relation to determine which tuple(s) to remove from the relation. This operator is the same as SQL. MODIFY - changes the values of one or more attributes in one or more tuples of a relation, as identified by a condition operating on the attributes of the relation. This is equivalent to SQL UPDATE. Unit 3.3 - Relational Algebra 1 4

Operators - Retrieval There are two groups of operations: Mathematical set theory based relations: UNION, INTERSECTION, DIFFERENCE, and CARTESIAN PRODUCT. Special database operations: SELECT (not the same as SQL SELECT), PROJECT, and JOIN. Unit 3.3 - Relational Algebra 1 5

Relational SELECT SELECT is used to obtain a subset of the tuples of a relation that satisfy a select condition. For example, find all employees born after 1st Jan 1950: SELECT dob > 01/JAN/1950 (employee) Unit 3.3 - Relational Algebra 1 6

Relational PROJECT The PROJECT operation is used to select a subset of the attributes of a relation by specifying the names of the required attributes. For example, to get a list of all employees surnames and employee numbers: PROJECT surname,empno (employee) Unit 3.3 - Relational Algebra 1 7

SELECT and PROJECT SELECT and PROJECT can be combined together. For example, to get a list of employee numbers for employees in department number 1: PROJECT empno (SELECT depno = 1 (employee)) Mapping this back to SQL gives: SELECT empno FROM employee WHERE depno = 1; Unit 3.3 - Relational Algebra 1 8

Set Operations - semantics Consider two relations R and S. UNION of R and S the union of two relations is a relation that includes all the tuples that are either in R or in S or in both R and S. Duplicate tuples are eliminated. INTERSECTION of R and S the intersection of R and S is a relation that includes all tuples that are both in R and S. DIFFERENCE of R and S the difference of R and S is the relation that contains all the tuples that are in R but that are not in S. Unit 3.3 - Relational Algebra 1 9

SET Operations - requirements For set operations to function correctly the relations R and S must be union compatible. Two relations are union compatible if they have the same number of attributes the domain of each attribute in column order is the same in both R and S. Unit 3.3 - Relational Algebra 1 10

UNION Example R F 4 S R UNION S A B C D E F E 1 2 2 3 5 4 4 Unit 3.3 - Relational Algebra 1 11

INTERSECTION Example R F 4 R NTERSECTION S S Unit 3.3 - Relational Algebra 1 12

DIFFERENCE Example R F 4 S R DIFFERENCE S F 4 S DIFFERENCE R Unit 3.3 - Relational Algebra 1 13

CARTESIAN PRODUCT The Cartesian Product is also an operator which works on two sets. It is sometimes called the CROSS PRODUCT or CROSS JOIN. It combines the tuples of one relation with all the tuples of the other relation. Unit 3.3 - Relational Algebra 1 14

CARTESIAN PRODUCT Example R F 4 S R CROSS S F 4 F 4 F 4 F 4 Unit 3.3 - Relational Algebra 1 15

JOIN Operator JOIN is used to combine related tuples from two relations: In its simplest form the JOIN operator is just the cross product of the two relations. As the join becomes more complex, tuples are removed within the cross product to make the result of the join more meaningful. JOIN allows you to evaluate a join condition between the attributes of the relations on which the join is undertaken. The notation used is R JOIN join condition S Unit 3.3 - Relational Algebra 1 16

JOIN Example R S ColA ColB F 4 SColA SColB R JOIN R.ColA = S.SColA S F 4 R JOIN R.ColB = S.SColB S Unit 3.3 - Relational Algebra 1 17

Natural Join Invariably the JOIN involves an equality test, and thus is often described as an equi-join. Such joins result in two attributes in the resulting relation having exactly the same value. A natural join will remove the duplicate attribute(s). In most systems a natural join will require that the attributes have the same name to identify the attribute(s) to be used in the join. This may require a renaming mechanism. If you do use natural joins make sure that the relations do not have two attributes with the same name by accident. Unit 3.3 - Relational Algebra 1 18

OUTER JOINs Notice that much of the data is lost when applying a join to two relations. In some cases this lost data might hold useful information. An outer join retains the information that would have been lost from the tables, replacing missing data with nulls. There are three forms of the outer join, depending on which data is to be kept. LEFT OUTER JOIN - keep data from the left-hand table RIGHT OUTER JOIN - keep data from the right-hand table FULL OUTER JOIN - keep data from both tables Unit 3.3 - Relational Algebra 1 19

OUTER JOIN Example 1 R S ColA ColB F 4 SColA SColB R LEFT OUTER JOIN R.ColA = S.SColA S - - F 4 - - R RIGHT OUTER JOIN R.ColA = S.SColA S - - Unit 3.3 - Relational Algebra 1 20

OUTER JOIN Example 2 R S ColA ColB F 4 SColA SColB R FULL OUTER JOIN R.ColA = S.SColA S - - F 4 - - - - Unit 3.3 - Relational Algebra 1 21