CS 461: Database Systems. Final Review. Julia Stoyanovich
|
|
- Lester Matthews
- 5 years ago
- Views:
Transcription
1 CS 461: Database Systems Final Review
2 Final exam logistics When: June 6, in class The same format as the midterm: open book, open notes 2 hours in length The exam is cumulative, it will include material from the first half of the term. However, we will likely have more of a focus on the material from the second half of the term. To study: go over lecture notes, midterm, homework / solutions 2
3 Normalization: important to know Closures, keys compute the closure of a set of attributes compute candidate keys of a relation check whether an FD follows from a set of FDs compute a minimal basis of a set of FDs Normal forms check whether a relation is in BCNF check whether a relation is in 3NF I will not ask you to produce a BCNF or a 3NF decomposition on the final exam 3
4 Closure of a set of attributes Suppose A = {A1,, An} is a set of attributes and S is a set of FDs. The closure of A under the FDs in S is the set of attributes B s.t. every relation that satisfies all the FDs in S also satisfies A B We denote the closure of {A 1, A 2,, A n } by {A 1, A 2,, A n } + Note that {A 1, A 2,, A n } {A 1, A 2,, A n } + 4
5 Computing the closure of a set of attributes Algorithm AttributeClosure Input: a set of attributes {A 1, A 2,, A n } and a set of FDs S Output: the closure {A 1, A 2,, A n } + 1. Split the FDs of S using the splitting rule, so that each FD has one attribute on the right 2.Initialize {A 1, A 2,, A n } + {A 1, A 2,, A n } 3. Repeatedly search for some FD B 1, B 2,, B m C such that {B 1, B 2,, B m } {A 1, A 2,, A n } + C {A 1, A 2,, A n } + 4.Stop when no more attributes can be added to {A 1, A 2,, A n } + 5
6 Closures and keys Q: How can we tell if a set of attributes A 1 A 2 A n is a candidate key or a superkey of a relation R? A: If {A 1, A 2,..., A n } + = all the attributes in R Q: How can we compute the candidate keys for R? A: Find all sets of attributes that functionally determine all other attributes and make sure these sets are minimal. 6
7 inimal basis of a set of FDs For a given relation R, there may exist several sets of FDs that are equivalent: - they give rise to the same closures of all subsets of R s attributes - the same sets of FDs follow from them - all such equivalent sets of FDs are called bases for S in R A minimal basis B is a set of FDs that satisfies 3 conditions 1. All FDs in B have 1 attribute on the right 2. If any FD is removed from B, the result is no longer a basis 3. If for any FD in B we remove 1 attribute on the left, the result is no longer a basis 7
8 Example R(ABCD) C B BC A A C BD A Find all candidate keys Check whether the following are minimal bases of the set of FDs. {AC D, D B} {D A, D B, D C} 8
9 Example Compute a projection of the set of FDs when R (ABCD) is projected onto ACD. R(ABCD) A B ; B C ; C D π ACD (R) 9
10 Example Compute a projection of the set of FDs when R (ABCD) is projected onto ACD. R(ABCD) A B ; B C ; C D π ACD (R) Compute closures of all subsets of attributes in the projected relation. {A} + = {A, B,C, D} {C} + = {C, D} = {C, D} + {D} + = {D} we stop here, since any set that includes A will have the same closure as A alone Compute FDs from these closures that involve only A,C,D on either side, remove redundant FDs (keeping only the minimal basis) T = {A C, C D} done! 10
11 Boyce-Codd Normal Form (BCNF) Let R be a relation schema, S be the set of FDs given to hold over R. R is in BCNF if, for every FD A 1 A 2 A n B 1 B 2 B m one of the following statements is true: 1. The FD is trivial: {B 1, B 2,, B m } {A 1, A 2,, A n } A 1 A 2 A n 2. is a candidate key of R A 1 A 2 A n 3. is a superkey of R In a BCNF relation, the only set of attributes that determines values for other attributes is a superkey! 11
12 Third Normal Form (3NF) Let R be a relation schema, S be the set of FDs given to hold over R. R is in 3NF if, for every FD A 1 A 2 A n B 1 B 2 B m one of the following statements is true: 1. The FD is trivial: {B 1, B 2,, B m } {A 1, A 2,, A n } same for BCNF 2. A 1 A 2 A n is a candidate key of R as{ 3. is a superkey of R A 1 A 2 A n B i 4. Each is part of some candidate key of R In contrast to BCNF, some redundancy is possible with 3NF. This normal form is a compromise, needed when no dependency-preserving decomposition into BCNF exists. 12
13 Example Find all candidate keys of the given set of FDs. Check whether R is in BCNF, 3NF R( ABCD) ABD C ; A B ; AB C ; B A {A} + = {ABC} {AD} + = {ABCD} {BD} + = {ABCD} {B} + = {ABC} 13
14 Example R(ABCD) AB C ; D B ; AC D (a) list candidate keys of R AB, AC, AD (b) does this FD follow from the set of FDs above? AD B Yes. To check this, we must check whether B is in the closure of {AD}. We know that this is the case because, as we saw in (a), {AD} is a candidate key of R, and so all attributes are in the closure of {AD}. (c) is R in BCNF? is it in 3NF? In 3NF but not in BCNF 14
15 2-way merge-sort example with N=7 pages 3,4 6,2 9,4 8,7 5,6 3,1 2 3,4 2,6 4,9 7,8 5,6 1,3 2 2,3 4,6 2,3 4,4 6,7 8,9 4,7 8,9 1,3 5,6 2 1,2 3,5 6 Input file PASS 0 1-page runs PASS 1 2-page runs PASS 2 4-page runs PASS 3 1,2 2,3 3,4 4,5 6,6 7,8 9 8-page runs 15
16 2-way merge-sort suppose the input occupies N = 2 k disk pages What is the cost of this algorithm? In each pass, we read each page process it, and write it out: 2 disk I/Os per page, per pass There are k = log 2N + 1 passes The over-all cost is 2N (log 2N + 1) I/Os INPUT 1 INPUT 2 OUTPUT Disk ain memory buffers Disk 16
17 2-way external merge sort A file with 10,000 records, each record is 1KB. Size of a page/block is 64KB (i.e., 64 records / block). What is the number of passes, the cost of 2-way external merge-sort? In this dataset, there are ceil(10,000 / 64) = 157 pages that must be sorted. In two-way external merge-sort, we use 1 memory block in pass 0 (each 64-record block is sorted), and 3 memory blocks in subsequent passes (pairs of adjacent sorted runs are merged). To sort 157 pages, we will need 1 + ceil(log2157) = 9 passes. Each page is read and written once on each pass (2 I/Os per page per pass). Thus, the total cost of two-way external merge-sort on this dataset is 2 * 157 * 9 = 2,826 I/Os. 17
18 Generalization: external merge-sort B: block size : main memory size N: input size (blocks) R: size of 1 record N records, divided into NR / sorted runs of / R records each final sorted result 18
19 External merge-sort example A file with 10,000 records, each record is 1KB. Size of a page/ block is 64KB (i.e., 64 records / block). With memory size of 320KB, how many passes for generalized external merge sort? What is the cost? emory (its 320 / 64 = 5 pages. All are used for sorting in pass 0. All but 1 are used for sorting in subsequent runs, the remaining page is used for output. In phase 0 of generalized external merge-sort, we read in and sort 320KB (5 blocks worth) at a time, creating ceil(157/5) = 32 sorted runs of 5 blocks each. Then in subsequent passes we merge 5-1=4 neighboring runs. We need ceil(log432)=3 passes to complete sorting. That s a total of 3 passes, with 2 I/Os per page per pass, for a total of 2 * 157 * 4 = 1256 I/Os. 19
20 Basic file organization Heap files: good for full file scans or frequent updates unordered files insert at the end of file assumes equality selection on key, exactly one match (why?) Sorted files: good for range queries on sort field(s) need external sort to keep sorted compacted after deletion assumes selection on sort field(s) Hashed files: good for selection on equality collection of buckets with primary & overflow pages hashing function h(r) = bucket for record r each bucket is a heap file 20
21 Cost of operations p(t) - number of data pages in table T r(t) - number of records in table T D - time to read or write a disk page Heap File Sorted File Hashed File Scan all recs p(t) D p(t) D 1.25 p(t) D * Equality Search p(t) D / 2 D log 2 p(t) D Range Search p(t) D D log 2 p(t) + (# pages with matches) 1.25 p(t) D Insert 2D Search + p(t) D 2D Delete Search + D Search + p(t) D 2D * assuming no overflow bucket, 80% page occupancy 21
22 Access paths An access path is a method of retrieving tuples: file scan, or index that matches a selection in the query An index matches a conjunction of terms if it can be used to retrieve all data values that match this conjunction of terms. A tree index matches a conjunction of terms that involve only attributes in a prefix of the search key. e.g., tree index <a,b,c> matches the selection a=5 AND b=3; it also matches a=5 AND b>4; it does not match b=3. A hash index matches a conjunction of terms that has a term attribute=value for every attribute in the search key of the index. e.g., hash index on <a,b,c> matches a=b AND b=3 AND c=5; it does not match b=3; or a=5 and b=5; or a>5 AND b=3 and c=5 22
23 Clustered vs. unclustered index Data entries (Index File) (Data file) Data entries CLUSTERED Data Records Data Records UNCLUSTERED 23
24 Using an index for selection Sailors (sid:int, sname: string, rating:int, age:real) Reserves (sid:int, bid:int, day:date, rname:string) SELECT * FRO Reserves R WHERE R.rname < C% Reserves (R): each tuple us 40 bytes long, 100 tuples per page, 1000 pages Sailors (S): each tuple is 50 bytes long, 80 tuples per page, 500 pages Cost of finding qualifying data entries (typically small) plus cost of retrieving records (could be large) Example: assuming uniform distribution of names, about 10% of tuples qualify (100 pages, 10,000 tuples). with a clustered index, cost is little more than 100 I/Os with an unclustered index, cost is up to 10,000 I/Os! 24
25 Access paths: example Employees (eid, name, salary, age, did); Departments (did, budget, floor, manager_eid); Salaries from $10K to $100K ages from 20 to 80; 5 employees per department; 10 floors; budgets from $10K to $1. Uniform, uncorrelated values. Q1. Print name, age, salary for all employees A1: clustered hash index on (name, age, salary) of Employees A2: unclustered hash index on (name, age, salary) of Employees A3: clustered B+-tree index on (name, age, salary) of Employees A4: unclustered hash index on (eid, did) of Employees A5: no index 25
26 Access paths: example Employees (eid, name, salary, age, did); Departments (did, budget, floor, manager_eid); Salaries from $10K to $100K ages from 20 to 80; 5 employees per department; 10 floors; budgets from $10K to $1. Uniform, uncorrelated values. Q2. Find dids of departments on the 10th floor with budget < $15K A1: clustered hash index on (floor) of Departments A2: clustered hash index on (floor, budget) of Departments A3: clustered B+-tree index on (floor, budget) of Departments A4: clustered B+-tree index on (budget) of Departments A5: no index 26
27 Access paths: example Sailors (sid, name, rating, age); Sids from 1 to 100K, ratings from 1 to 10, ages from 20 to 80. Uniform, uncorrelated values. Q1. Print name, age, rating of all sailors A1: sequential scan of sorted file, sorted on (id) A2: clustered hash index on (rating) A3: unclustered hash index on (id) A4: unclustered hash index on (age, rating) A5: unclustered hash index on (name, age) A6: clustered B+-tree index on (name, age) A7: unclustered B+-tree index on (age, rating) 27
28 Access paths: example Sailors (sid, name, rating, age); Sids from 1 to 100K, ratings from 1 to 10, ages from 20 to 80. Uniform, uncorrelated values. Q2. Print name, age, rating of the sailor with sid 123 A1: sequential scan of sorted file, sorted on (id) A2: clustered hash index on (rating) A3: unclustered hash index on (id) A4: unclustered hash index on (age, rating) A5: unclustered hash index on (name, age) A6: clustered B+-tree index on (name, age) A7: unclustered B+-tree index on (age, rating) 28
29 Access paths: example Sailors (sid, name, rating, age); Sids from 1 to 100K, ratings from 1 to 10, ages from 20 to 80. Uniform, uncorrelated values. Q3. Count sailors with rating = 5 and age = 40 A1: sequential scan of sorted file, sorted on (id) A2: clustered hash index on (rating) A3: unclustered hash index on (id) A4: unclustered hash index on (age, rating) A5: unclustered hash index on (name, age) A6: clustered B+-tree index on (name, age) A7: unclustered B+-tree index on (age, rating) 29
30 Access paths: another example Employees (ssn, name, salary, age, did); 100,000 employees, 10 employee records per disk page. Stored on disk in a sorted file (alternative 1), with did as the sort key. Salaries from 0 to $100K; ages from 20 to 80; 50 employees per department. Uniform, uncorrelated values. Q1. Compute the number of employees whose salary is $35K and who work in department 177. Q2. List name, age, salary of employee with eid= Q3. Compute the number of employees who are between 30 and 35 years old. For each query: (1) List indexes that would match the query. (2) What index would you build? (3) What is the cost of using that index to answer this query? 30
31 Relational algebra and SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (a) List eids of pilots certified to fly Boeing. (b) List names of pilots certified to fly Boeing. 31
32 Relational algebra and SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (a) List eids of pilots certified to fly Boeing. π eid ((σ name='boeing' Aircraft) aid Certified) (b) List names of pilots certified to fly Boeing. π ename (Employees eid ((σ name='boeing' Aircraft) aid Certified)) 32
33 Relational algebra and SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (c) List names of aircraft that can be used on non-stop flights from Bonn to adras. 33
34 Relational algebra and SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (c) List names of aircraft that can be used on non-stop flights from Bonn to adras. π aname ((σ origin='bonn' dest='adras' Flights) range dist Aircraft) 34
35 Relational algebra and SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (d) Find names of pilots who can operate planes with a range greater than 3,000 miles but are not certified on any Boeing aircraft. 35
36 Relational algebra and SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (d) Find names of pilots who can operate planes with a range greater than 3,000 miles but are not certified on any Boeing aircraft. π ename (Employees eid (π eid ((σ range>3000 Aircraft) aid Certified) π eid ((σ name='boeing' Aircraft) aid Certified))) not the same as: π ename (Employees eid (π eid ((σ range>3000 name 'Boeing' Aircraft) aid Certified))) 36
37 SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (e) List eids of pilots certified to fly exactly 3 aircraft. 37
38 SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (e) List eids of pilots certified to fly exactly 3 aircraft. select eid from Certified group by eid having count(*) = 3 38
39 SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (f) List aids of aircraft that can be used on flight AF007, along with an average salary of pilots who are certified to operate these aircraft. 39
40 SQL Flights (flno: int, origin: string, destintation: string, dist: int, departs:date, arrives: date) Aircraft (aid: int, aname: string, range: int) Employees (eid: int, ename: string, salary: int) Certified (eid: int, aid: int) (f) List aids of aircraft that can be used on flight AF007, along with an average salary of pilots who are certified to operate these aircraft. select avg(e.salary), A.aid from Flights F, Aircraft A, Certified C, Employees E where F.flno = 'AF007' and F.dist <= A.range and A.aid = C.aid and C.eid = E.eid group by A.aid 40
41 When writing queries For relational algebra, do worry about efficiency: avoid Cartesian product whenever possible, push selections For SQL, do worry about efficiency and readability: avoid nested queries if your query can be expressed with a join use group by / having as appropriate, not a subquery and a where clause in the outer use standard notation, like we covered in class, e.g., no need to write inner join, and do write your queries by hand For both SQL and relational algebra: do not join with relations unnecessarily. You should have exactly the right number of tables in the from clause of a SQL query, no more no less 41
42 ER modeling Draw an ER diagram that encodes the following business rules. Clearly mark all key and participation constraints. Chefs work at restaurants. A chef is uniquely identified by an SSN, and is also described by a name and a cuisine in which she specialized. A restaurant is uniquely identified by a combination of name and city. Each chef works in at least one restaurant, and each restaurant must have at least one chef working at it. Some chefs own restaurants, and if a chef owns a restaurant - she is its sole owner. 42
43 ER modeling Draw an ER diagram that encodes the following business rules. Clearly mark all key and participation constraints. Chefs work at restaurants. A chef is uniquely identified by an SSN, and is also described by a name and a cuisine in which she specialized. A restaurant is uniquely identified by a combination of name and city. Each chef works in at least one restaurant, and each restaurant must have at least one chef working at it. Some chefs own restaurants, and if a chef owns a restaurant - she is its sole owner. ssn( name( cuisine( own( name( city( CHEFS( RESTAURANTS( work_at( 43
44 ER to relational 44
45 ER to relational create table Teams ( name varchar(32) primary key); create table Athletes ( name varchar(32), dob date, team_name varchar(32), primary key (name, dob), foreign key (team_name) references Teams (name)); create table Sports ( name varchar(32) primary key, olympic char(3) ); create table Athletes_play_Sports ( athlete_name, sport_name, primary key (athlete_name, sport_name), foreign key (athlete_name) references Athletes(name), foreign key (sport_name) references Sports(name) ); 45
46 ER to relational name) party) name) PRESIDENTS) running_mate) VICE_PRESIDENTS) 46
47 ER to relational name) party) name) PRESIDENTS) running_mate) VICE_PRESIDENTS) create table Presidents_VPs ( president_name varchar(32) primary key, vp_name varchar(32) unique not null, party varchar(32) ); 47
48 Binary vs. ternary relationship sets name) party) name) PRESIDENT) running_mate) VICE_PRESIDENT) name) name) PRESIDENT) running_mate) VICE_PRESIDENT) name) Party) 48
49 And now with constraints name) name) PRESIDENT) running_mate) VICE_PRESIDENT) name) Party) 49
50 And now with constraints name) name) PRESIDENT) running_mate) VICE_PRESIDENT) name) Party) create table Parties ( name varchar(32) primary key ); create table Presidents_VPs ( president_name varchar(32) primary key, vp_name varchar(32) unique not null, party varchar(32) not null, foreign key party references Parties(name) ); 50
51 Candidate keys, superkeys Consider a relation schema and business rules below. Dancers (name: string, dob: date, stage_name: string, company: string) No two dancers have the same combination of name and date of birth (dob). No two dancers have the same combination of stage name and company. A name, a dob and a stage name have to be specified for each dancer, but not all dancers belong to a company. What are the candidate keys? Which of these would be appropriate for a primary key? Which are not appropriate for a primary key? What are the superkeys? Write a valid create table statement. 51
TotalCost = 3 (1, , 000) = 6, 000
156 Chapter 12 HASH JOIN: Now both relations are the same size, so we can treat either one as the smaller relation. With 15 buffer pages the first scan of S splits it into 14 buckets, each containing about
More information192 Chapter 14. TotalCost=3 (1, , 000) = 6, 000
192 Chapter 14 5. SORT-MERGE: With 52 buffer pages we have B> M so we can use the mergeon-the-fly refinement which costs 3 (M + N). TotalCost=3 (1, 000 + 1, 000) = 6, 000 HASH JOIN: Now both relations
More informationCSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization
CSE 544 Principles of Database Management Systems Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization References R&G Book. Chapter 19: Schema refinement and normal forms Also relevant to
More informationDATABASE MANAGEMENT SYSTEMS
www..com Code No: N0321/R07 Set No. 1 1. a) What is a Superkey? With an example, describe the difference between a candidate key and the primary key for a given relation? b) With an example, briefly describe
More informationFinal Review. Zaki Malik November 20, 2008
Final Review Zaki Malik November 20, 2008 Basic Operators Covered Renaming If two relations have the same attribute, disambiguate the attributes by prefixing the attribute with the name of the relation
More informationDatabase Systems. Announcement. December 13/14, 2006 Lecture #10. Assignment #4 is due next week.
Database Systems ( 料 ) December 13/14, 2006 Lecture #10 1 Announcement Assignment #4 is due next week. 2 1 Overview of Query Evaluation Chapter 12 3 Outline Query evaluation (Overview) Relational Operator
More informationA7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS
A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered
More informationCS 461: Database Systems. Midterm review. Julia Stoyanovich
CS 461: Database Systems Midterm review Julia Stoyanovich (stoyanovich@drexel.edu) Sets Let us denote by M the set of all musicians, by R the set of rock musicians, by B the set of blues musicians, by
More informationCOSC Dr. Ramon Lawrence. Emp Relation
COSC 304 Introduction to Database Systems Normalization Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Normalization Normalization is a technique for producing relations
More informationEvaluation of Relational Operations
Evaluation of Relational Operations Chapter 14 Comp 521 Files and Databases Fall 2010 1 Relational Operations We will consider in more detail how to implement: Selection ( ) Selects a subset of rows from
More informationImplementation of Relational Operations
Implementation of Relational Operations Module 4, Lecture 1 Database Management Systems, R. Ramakrishnan 1 Relational Operations We will consider how to implement: Selection ( ) Selects a subset of rows
More informationSchema Refinement and Normal Forms
Schema Refinement and Normal Forms Chapter 19 Quiz #2 Next Wednesday Comp 521 Files and Databases Fall 2010 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational
More informationMidterm Exam (Version B) CS 122A Spring 2017
NAME: SOLUTION SEAT NO.: STUDENT ID: Midterm Exam (Version B) CS 122A Spring 2017 Max. Points: 100 (Please read the instructions carefully) Instructions: - The total time for the exam is 80 minutes; be
More informationNormalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design
1 Normalization What and Why Normalization? To remove potential redundancy in design Redundancy causes several anomalies: insert, delete and update Normalization uses concept of dependencies Functional
More informationPhysical Design. Elena Baralis, Silvia Chiusano Politecnico di Torino. Phases of database design D B M G. Database Management Systems. Pag.
Physical Design D B M G 1 Phases of database design Application requirements Conceptual design Conceptual schema Logical design ER or UML Relational tables Logical schema Physical design Physical schema
More informationIMPORTANT: Circle the last two letters of your class account:
Fall 2001 University of California, Berkeley College of Engineering Computer Science Division EECS Prof. Michael J. Franklin FINAL EXAM CS 186 Introduction to Database Systems NAME: STUDENT ID: IMPORTANT:
More informationFaloutsos 1. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Outline
Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications Lecture #14: Implementation of Relational Operations (R&G ch. 12 and 14) 15-415 Faloutsos 1 introduction selection projection
More informationDatabase Management Systems Paper Solution
Database Management Systems Paper Solution Following questions have been asked in GATE CS exam. 1. Given the relations employee (name, salary, deptno) and department (deptno, deptname, address) Which of
More informationExample Examination. Allocated Time: 100 minutes Maximum Points: 250
CS542 EXAMPLE EXAM Elke A. Rundensteiner Example Examination Allocated Time: 100 minutes Maximum Points: 250 STUDENT NAME: General Instructions: This test is a closed book exam (besides one cheat sheet).
More informationIMPORTANT: Circle the last two letters of your class account:
Fall 2004 University of California, Berkeley College of Engineering Computer Science Division EECS MIDTERM II CS 186 Introduction to Database Systems Prof. Michael J. Franklin NAME: D.B. Guru STUDENT ID:
More informationAnnouncement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17
Announcement CompSci 516 Database Systems Lecture 10 Query Evaluation and Join Algorithms Project proposal pdf due on sakai by 5 pm, tomorrow, Thursday 09/27 One per group by any member Instructor: Sudeepa
More informationExamples of Physical Query Plan Alternatives. Selected Material from Chapters 12, 14 and 15
Examples of Physical Query Plan Alternatives Selected Material from Chapters 12, 14 and 15 1 Query Optimization NOTE: SQL provides many ways to express a query. HENCE: System has many options for evaluating
More informationCS 564 Final Exam Fall 2015 Answers
CS 564 Final Exam Fall 015 Answers A: STORAGE AND INDEXING [0pts] I. [10pts] For the following questions, clearly circle True or False. 1. The cost of a file scan is essentially the same for a heap file
More informationDatabase Applications (15-415)
Database Applications (15-415) DBMS Internals- Part VI Lecture 14, March 12, 2014 Mohammad Hammoud Today Last Session: DBMS Internals- Part V Hash-based indexes (Cont d) and External Sorting Today s Session:
More informationUNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division
UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division CS186 Eben Haber Fall 2003 Midterm Midterm Exam: Introduction to Database Systems This exam has seven problems,
More informationImplementing Relational Operators: Selection, Projection, Join. Database Management Systems, R. Ramakrishnan and J. Gehrke 1
Implementing Relational Operators: Selection, Projection, Join Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Readings [RG] Sec. 14.1-14.4 Database Management Systems, R. Ramakrishnan and
More informationMidterm Review CS634. Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke
Midterm Review CS634 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Coverage Text, chapters 8 through 15 (hw1 hw4) PKs, FKs, E-R to Relational: Text, Sec. 3.2-3.5, to pg.
More informationQUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS
QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS SCHEMA DESIGN & RELATIONAL ALGEBRA A database schema is the skeleton structure that represents the logical view of the entire database Logical design of
More informationEvaluation of Relational Operations. Relational Operations
Evaluation of Relational Operations Chapter 14, Part A (Joins) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Relational Operations v We will consider how to implement: Selection ( )
More informationUniversity of California, Berkeley. CS 186 Introduction to Databases, Spring 2014, Prof. Dan Olteanu MIDTERM
University of California, Berkeley CS 186 Introduction to Databases, Spring 2014, Prof. Dan Olteanu MIDTERM This is a closed book examination sided). but you are allowed one 8.5 x 11 sheet of notes (double
More informationCSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization
CSE 544 Principles of Database Management Systems Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization References R&G Book. Chapter 19: Schema refinement and normal forms Also relevant to this
More informationOverview of Implementing Relational Operators and Query Evaluation
Overview of Implementing Relational Operators and Query Evaluation Chapter 12 Motivation: Evaluating Queries The same query can be evaluated in different ways. The evaluation strategy (plan) can make orders
More informationCOMP7640 Assignment 2
COMP7640 Assignment 2 Due Date: 23:59, 14 November 2014 (Fri) Description Question 1 (20 marks) Consider the following relational schema. An employee can work in more than one department; the pct time
More informationDatabase Management
Database Management - 2011 Model Answers 1. a. A data model should comprise a structural part, an integrity part and a manipulative part. The relational model provides standard definitions for all three
More informationSOLUTIONS TO THE FINAL EXAMINATION Introduction to Database Design Spring 2011
SOLUTIONS TO THE FINAL EXAMINATION Introduction to Database Design Spring 2011 IT University of Copenhagen June 7, 2011 1 Database design (25 points) a) b) Figure 1 shows the ER diagram. create table rer
More informationPrinciples of Data Management. Lecture #9 (Query Processing Overview)
Principles of Data Management Lecture #9 (Query Processing Overview) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Today s Notable News v Midterm
More informationAdministriva. CS 133: Databases. General Themes. Goals for Today. Fall 2018 Lec 11 10/11 Query Evaluation Prof. Beth Trushkowsky
Administriva Lab 2 Final version due next Wednesday CS 133: Databases Fall 2018 Lec 11 10/11 Query Evaluation Prof. Beth Trushkowsky Problem sets PSet 5 due today No PSet out this week optional practice
More informationQuery Processing: The Basics. External Sorting
Query Processing: The Basics Chapter 10 1 External Sorting Sorting is used in implementing many relational operations Problem: Relations are typically large, do not fit in main memory So cannot use traditional
More informationFunctional Dependencies CS 1270
Functional Dependencies CS 1270 Constraints We use constraints to enforce semantic requirements on a DBMS Predicates that the DBMS must ensure to be always true. Predicates are checked when the DBMS chooses
More informationRELATIONAL OPERATORS #1
RELATIONAL OPERATORS #1 CS 564- Spring 2018 ACKs: Jeff Naughton, Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? Algorithms for relational operators: select project 2 ARCHITECTURE OF A DBMS query
More informationCS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #10: Query Processing
CS 4604: Introduction to Database Management Systems B. Aditya Prakash Lecture #10: Query Processing Outline introduction selection projection join set & aggregate operations Prakash 2018 VT CS 4604 2
More informationMASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2015 Quiz I
Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.830 Database Systems: Fall 2015 Quiz I There are 12 questions and 13 pages in this quiz booklet. To receive
More informationMidterm 2: CS186, Spring 2015
Midterm 2: CS186, Spring 2015 Prof. J. Hellerstein You should receive a double-sided answer sheet and an 8-page exam. Mark your name and login on both sides of the answer sheet, and in the blanks above.
More informationUNIT 3 DATABASE DESIGN
UNIT 3 DATABASE DESIGN Objective To study design guidelines for relational databases. To know about Functional dependencies. To have an understanding on First, Second, Third Normal forms To study about
More informationCost-based Query Sub-System. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Last Class.
Cost-based Query Sub-System Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Queries Select * From Blah B Where B.blah = blah Query Parser Query Optimizer C. Faloutsos A. Pavlo
More informationFunctional dependency theory
Functional dependency theory Introduction to Database Design 2012, Lecture 8 Course evaluation Recalling normal forms Functional dependency theory Computing closures of attribute sets BCNF decomposition
More information2011 DATABASE MANAGEMENT SYSTEM
Name :. Roll No. :..... Invigilator s Signature :.. CS/B.TECH(IT)/SEM-6/IT-604/2011 2011 DATABASE MANAGEMENT SYSTEM Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks.
More informationCSE 444 Midterm Test
CSE 444 Midterm Test Spring 2007 Name: Total time: 50 Question 1 /40 Question 2 /30 Question 3 /30 Total /100 1 1 SQL [40 points] Consider a database of social groups that allows people to become members
More information15-415/615 Faloutsos 1
Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #14: Implementation of Relational Operations (R&G ch. 12 and 14) 15-415/615 Faloutsos 1 Outline introduction selection
More informationName :. Roll No. :... Invigilator s Signature : DATABASE MANAGEMENT SYSTEM
Name :. Roll No. :..... Invigilator s Signature :.. CS/B.TECH(IT)/SEM-6/IT-604/2012 2012 DATABASE MANAGEMENT SYSTEM Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks.
More informationEvaluation of relational operations
Evaluation of relational operations Iztok Savnik, FAMNIT Slides & Textbook Textbook: Raghu Ramakrishnan, Johannes Gehrke, Database Management Systems, McGraw-Hill, 3 rd ed., 2007. Slides: From Cow Book
More informationQuery Evaluation Overview, cont.
Query Evaluation Overview, cont. Lecture 9 Feb. 29, 2016 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Architecture of a DBMS Query Compiler Execution Engine Index/File/Record
More informationCS 222/122C Fall 2016, Midterm Exam
STUDENT NAME: STUDENT ID: Instructions: CS 222/122C Fall 2016, Midterm Exam Principles of Data Management Department of Computer Science, UC Irvine Prof. Chen Li (Max. Points: 100) This exam has six (6)
More informationDatabase Systems External Sorting and Query Optimization. A.R. Hurson 323 CS Building
External Sorting and Query Optimization A.R. Hurson 323 CS Building External sorting When data to be sorted cannot fit into available main memory, external sorting algorithm must be applied. Naturally,
More informationFunctional Dependencies and Finding a Minimal Cover
Functional Dependencies and Finding a Minimal Cover Robert Soulé 1 Normalization An anomaly occurs in a database when you can update, insert, or delete data, and get undesired side-effects. These side
More informationModern Database Systems Lecture 1
Modern Database Systems Lecture 1 Aristides Gionis Michael Mathioudakis T.A.: Orestis Kostakis Spring 2016 logistics assignment will be up by Monday (you will receive email) due Feb 12 th if you re not
More informationCAS CS 460/660 Introduction to Database Systems. Query Evaluation II 1.1
CAS CS 460/660 Introduction to Database Systems Query Evaluation II 1.1 Cost-based Query Sub-System Queries Select * From Blah B Where B.blah = blah Query Parser Query Optimizer Plan Generator Plan Cost
More informationQuery Evaluation Overview, cont.
Query Evaluation Overview, cont. Lecture 9 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Architecture of a DBMS Query Compiler Execution Engine Index/File/Record Manager
More informationImplementing Joins 1
Implementing Joins 1 Last Time Selection Scan, binary search, indexes Projection Duplicate elimination: sorting, hashing Index-only scans Joins 2 Tuple Nested Loop Join foreach tuple r in R do foreach
More informationCSE 344 Midterm Nov 1st, 2017, 1:30-2:20
1 SQL 1. (36 points) Acompanymaintainsadatabaseabouttheiremployeesandprojectswiththefollowing schema. Employee(eid, name, salary) Project(pid, title, budget) WorksOn(eid, pid, year) WorksOn records which
More informationLecture 11 - Chapter 8 Relational Database Design Part 1
CMSC 461, Database Management Systems Spring 2018 Lecture 11 - Chapter 8 Relational Database Design Part 1 These slides are based on Database System Concepts 6th edition book and are a modified version
More informationInformal Design Guidelines for Relational Databases
Outline Informal Design Guidelines for Relational Databases Semantics of the Relation Attributes Redundant Information in Tuples and Update Anomalies Null Values in Tuples Spurious Tuples Functional Dependencies
More informationEvaluation of Relational Operations
Evaluation of Relational Operations Chapter 12, Part A Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Relational Operations We will consider how to implement: Selection ( ) Selects a subset
More informationOverview of Query Evaluation. Chapter 12
Overview of Query Evaluation Chapter 12 1 Outline Query Optimization Overview Algorithm for Relational Operations 2 Overview of Query Evaluation DBMS keeps descriptive data in system catalogs. SQL queries
More informationElmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2 Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant
More informationExam. Question: Total Points: Score:
FS 2016 Data Modelling and Databases Date: June 9, 2016 ETH Zurich Systems Group Prof. Gustavo Alonso Exam Name: Question: 1 2 3 4 5 6 7 8 9 10 11 Total Points: 15 20 15 10 10 15 10 15 10 10 20 150 Score:
More informationMASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2009 Quiz I Solutions
Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.830 Database Systems: Fall 2009 Quiz I Solutions There are 15 questions and 12 pages in this quiz booklet.
More informationSpring 2013 CS 122C & CS 222 Midterm Exam (and Comprehensive Exam, Part I) (Max. Points: 100)
Spring 2013 CS 122C & CS 222 Midterm Exam (and Comprehensive Exam, Part I) (Max. Points: 100) Instructions: - This exam is closed book and closed notes but open cheat sheet. - The total time for the exam
More informationHomework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please)
Virginia Tech. Computer Science CS 4604 Introduction to DBMS Spring 2016, Prakash Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please) Reminders: a. Out of 100 points.
More informationChapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases
Chapter 10 Functional Dependencies and Normalization for Relational Databases Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant
More informationCompSci 516 Data Intensive Computing Systems
CompSci 516 Data Intensive Computing Systems Lecture 9 Join Algorithms and Query Optimizations Instructor: Sudeepa Roy CompSci 516: Data Intensive Computing Systems 1 Announcements Takeaway from Homework
More informationChapter 10. Normalization. Chapter Outline. Chapter Outline(contd.)
Chapter 10 Normalization Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant Information in Tuples and Update Anomalies 1.3 Null
More informationDesign Theory for Relational Databases
By Marina Barsky Design Theory for Relational Databases Lecture 15 Functional dependencies: formal definition X Y is an assertion about a relation R that whenever two tuples of R agree on all the attributes
More informationEvaluation of Relational Operations: Other Techniques. Chapter 14 Sayyed Nezhadi
Evaluation of Relational Operations: Other Techniques Chapter 14 Sayyed Nezhadi Schema for Examples Sailors (sid: integer, sname: string, rating: integer, age: real) Reserves (sid: integer, bid: integer,
More informationEvaluation of Relational Operations
Evaluation of Relational Operations Yanlei Diao UMass Amherst March 13 and 15, 2006 Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Relational Operations We will consider how to implement: Selection
More informationCS330. Query Processing
CS330 Query Processing 1 Overview of Query Evaluation Plan: Tree of R.A. ops, with choice of alg for each op. Each operator typically implemented using a `pull interface: when an operator is `pulled for
More informationExternal Sorting Implementing Relational Operators
External Sorting Implementing Relational Operators 1 Readings [RG] Ch. 13 (sorting) 2 Where we are Working our way up from hardware Disks File abstraction that supports insert/delete/scan Indexing for
More informationCMSC 461 Final Exam Study Guide
CMSC 461 Final Exam Study Guide Study Guide Key Symbol Significance * High likelihood it will be on the final + Expected to have deep knowledge of can convey knowledge by working through an example problem
More informationImplementation of Relational Operations: Other Operations
Implementation of Relational Operations: Other Operations Module 4, Lecture 2 Database Management Systems, R. Ramakrishnan 1 Simple Selections SELECT * FROM Reserves R WHERE R.rname < C% Of the form σ
More informationIndexing. Chapter 8, 10, 11. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1
Indexing Chapter 8, 10, 11 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Tree-Based Indexing The data entries are arranged in sorted order by search key value. A hierarchical search
More informationOverview of Query Evaluation. Overview of Query Evaluation
Overview of Query Evaluation Chapter 12 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Overview of Query Evaluation v Plan: Tree of R.A. ops, with choice of alg for each op. Each operator
More informationCS 186/286 Spring 2018 Midterm 1
CS 186/286 Spring 2018 Midterm 1 Do not turn this page until instructed to start the exam. You should receive 1 single-sided answer sheet and a 18-page exam packet. All answers should be written on the
More informationLassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems
Lassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems Last Name: First Name: Student ID: 1. Exam is 2 hours long 2. Closed books/notes Problem 1 (6 points) Consider
More informationThe University of British Columbia
The University of British Columbia Computer Science 304 Midterm Examination January 30, 2012 Time: 50 minutes Total marks: 40 Instructor: Rachel Pottinger ANSWER KEY (PRINT) (Last) (First) Signature This
More informationThis lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization.
This lecture Databases -Normalization I This lecture introduces normal forms, decomposition and normalization (GF Royle 2006-8, N Spadaccini 2008) Databases - Normalization I 1 / 23 (GF Royle 2006-8, N
More informationLecture #8 (Still More Relational Theory...!)
Introduction to Data Management Lecture #8 (Still More Relational Theory...!) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v
More informationImplementation of Relational Operations. Introduction. CS 186, Fall 2002, Lecture 19 R&G - Chapter 12
Implementation of Relational Operations CS 186, Fall 2002, Lecture 19 R&G - Chapter 12 First comes thought; then organization of that thought, into ideas and plans; then transformation of those plans into
More informationAdministrivia. CS186 Class Wrap-Up. News. News (cont) Top Decision Support DBs. Lessons? (from the survey and this course)
Administrivia CS186 Class Wrap-Up R&G Chapters 1-28 Lecture 28 Final Exam Friday 12/12, 5pm 8pm, Room 4 LeConte You may have 2 pages of notes, both sides The exam is cumulative Final Exam Review Tuesday
More informationINSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad
Course Name Course Code Class Branch INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 04 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK : DATABASE MANAGEMENT SYSTEMS
More informationUniversity of Massachusetts Amherst Department of Computer Science Prof. Yanlei Diao
University of Massachusetts Amherst Department of Computer Science Prof. Yanlei Diao CMPSCI 445 Midterm Practice Questions NAME: LOGIN: Write all of your answers directly on this paper. Be sure to clearly
More informationStorage and Indexing
CompSci 516 Data Intensive Computing Systems Lecture 5 Storage and Indexing Instructor: Sudeepa Roy Duke CS, Spring 2016 CompSci 516: Data Intensive Computing Systems 1 Announcement Homework 1 Due on Feb
More informationThe Relational Data Model
The Relational Data Model Lecture 6 1 Outline Relational Data Model Functional Dependencies Logical Schema Design Reading Chapter 8 2 1 The Relational Data Model Data Modeling Relational Schema Physical
More informationExamination examples
Examination examples Databasteknik (5 hours) 1. Relational Algebra & SQL (4 pts total; 2 pts each). Part A Consider the relations R(A, B), and S(C, D). Of the following three equivalences between expressions
More informationChapter 14. Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies
Chapter 14 Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies Copyright 2012 Ramez Elmasri and Shamkant B. Navathe Chapter Outline 1 Informal Design Guidelines
More informationDatabase Management Systems (CS 601) Assignments
Assignment Set I : Introduction (CO1) DBA s are the highest paid professionals among other database employees -Justify. What makes a DBA different from the other SQL developers? Why is the mapping between
More informationDatabases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24
Databases -Normalization I (GF Royle, N Spadaccini 2006-2010) Databases - Normalization I 1 / 24 This lecture This lecture introduces normal forms, decomposition and normalization. We will explore problems
More informationDatabase Design and Tuning
Database Design and Tuning Chapter 20 Comp 521 Files and Databases Spring 2010 1 Overview After ER design, schema refinement, and the definition of views, we have the conceptual and external schemas for
More informationHash-Based Indexing 165
Hash-Based Indexing 165 h 1 h 0 h 1 h 0 Next = 0 000 00 64 32 8 16 000 00 64 32 8 16 A 001 01 9 25 41 73 001 01 9 25 41 73 B 010 10 10 18 34 66 010 10 10 18 34 66 C Next = 3 011 11 11 19 D 011 11 11 19
More informationAnnouncements. Reading Material. Recap. Today 9/17/17. Storage (contd. from Lecture 6)
CompSci 16 Intensive Computing Systems Lecture 7 Storage and Index Instructor: Sudeepa Roy Announcements HW1 deadline this week: Due on 09/21 (Thurs), 11: pm, no late days Project proposal deadline: Preliminary
More informationCSE 562 Database Systems
Goal CSE 562 Database Systems Question: The relational model is great, but how do I go about designing my database schema? Database Design Some slides are based or modified from originals by Magdalena
More information