Principles of Database Systems CSE 544p. Lecture #1 September 28, 2011
|
|
- Brianna Black
- 5 years ago
- Views:
Transcription
1 Principles of Database Systems CSE 544p Lecture #1 September 28,
2 Staff Instructor: Dan Suciu CSE 662, Office hours: Wednesdays, 5:30-6:20 TAs: Sandra Fan, 2
3 CommunicaRons Web page: hsp:// Lectures will be available here Homework will be posted here Announcements may be posted here Mailing list: Announcements, group discussions If you registered, you are automarcally subscribed 3
4 Textbook(s) Main textbook: Database Management Systems, Ramakrishnan and Gehrke Second textbook: Database Systems: The Complete Book, Garcia- Molina, Ullman, Widom 4
5 Course Format Lectures Wednesdays, 6:30-9:20 7 Homework Assignments Take- home Final 5
6 Grading Homework: 70 % Take- home Final: 30% 6
7 Homework Assignments 1. SQL 2. Conceptual design 3. JAVA/SQL 4. TransacRons 5. Database tuning 6. XML/XPath/XQuery 7. Pig LaRn, on AWS Due: Mondays, by 11:59pm. Three late days per person 7
8 Take- home Final Posted on December 8, at 11:59pm Due on December 10, by 10:00pm No late days/hours/minutes/seconds 8
9 Sohware Tools Postgres: Preferred usage: download from download hsp:// Other opron: use postgres on lab machines SQL Server 2008 Download client from hsp://msdnaa.cs.washington.edu Username is your address Doesn t work? ms- sw- admin@cs.washington.edu Connect to IPROJSRV (may need tunneling) OK to use you own server, just import IMDB Xquery: download one interpreter from Preferred: Saxon: hsp://saxon.sourceforge.net/ (from apache; very popular) Others: Zorba: hsp:// xquery.com/ (I used this one: ½ day installaron) Galax: hsp://galax.sourceforge.net/ (great in the past, seems less well maintained) Pig LaRn: We will run it on Amazon Web Services You may download from hsp://hadoop.apache.org/pig/, but you won t need it 9
10 Accessing SQL Server SQL Server Management Studio Server Type = Database Engine Server Name = IPROJSRV AuthenRcaRon = SQL Server AuthenRcaRon Login = your UW address (not the CSE ) Password = [in class] Must connect from within CSE, or must use tunneling AlternaRvely: install your own, get it from MSDNAA (see earlier slide) Then play with IMDB, start working on HW 1 10
11 Rest of Today s Lecture Overview of DBMS Overview of the course content SQL 11
12 Database What is a database? Give examples of databases 12
13 Database What is a database? A collecron of files storing related data Give examples of databases Accounts database; payroll database; UW s students database; Amazon s products database; airline reservaron database 13
14 Database Management System What is a DBMS? Give examples of DBMS 14
15 Database Management System What is a DBMS? A big C program wri;en by someone else that allows us to manage efficiently a large database and allows it to persist over long periods of Bme Give examples of DBMS DB2 (IBM), SQL Server (MS), Oracle, Sybase MySQL, Postgres, SQL for Nerds, Greenspun, hsp://philip.greenspun.com/sql/ (Chap 1) 15
16 Market Shares From 2006 Gartner report: IBM: 21% market with $3.2BN in sales Oracle: 47% market with $7.1BN in sales Microsoh: 17% market with $2.6BN in sales 16
17 An Example The Internet Movie Database hsp:// EnRRes: Actors (800k), Movies (400k), Directors, RelaRonships: who played where, who directed what, 17
18 Key concept 1: RelaRonal Data Model Actor: id fname lname gender Cast: pid mid Tom Hanks M Amy Hanks F Movie: id Name year Toy Story
19 Key concept 2: DeclaraRve Query SELECT * FROM Actor Language SQL SELECT * FROM Actor WHERE lname = Hanks We write what we want, not how we want it. SELECT count(*) FROM Actor 19
20 Key concept 3: Data Independence SELECT * FROM Actor, Casts, Movie WHERE lname='hanks' and Actor.id = Casts.pid and Casts.mid=Movie.id and Movie.year= k actors, 3.5M casts, 380k movies; How can it be so fast? Physical data independence: query is independent of physical storage 20
21 How Can We Evaluate the Query? Actor: Cast: Movie: id fname lname gender pid mid id Name year... Hanks Plan 1:.... [ in class ] Plan 2:.... [ in class ] 21
22 Indexes: on Actor.lName, on Movie.year AlternaRve query plans: σ lname= Hanks σ year=1995 σ lname= Hanks σ year=1995 Actor Cast Movie Actor Cast Movie Query oprmizaron Database StaRsRcs histograms, synopses, etc 22
23 Key concept 4: TransacRons Recovery from systems failures: Transfer $100 from account 1 to account 2: X = Read(Account_1); X.amount = X.amount - 100; Write(Account_1, X); Y = Read(Account_2); Y.amount = Y.amount + 100; Write(Account_2, Y); What is the problem? CRASH! 23
24 Concurrency Control Overdrahing an account: User 1: User 2: X = Read(Account); if (X.amount >= 100) { dispense_money( ); X.amount = X.amount 100; } else error( Insufficient funds ); X = Read(Account); if (X.amount >= 100) { dispense_money( ); X.amount = X.amount 100; } else error( Insufficient funds ); What can go wrong? 24
25 TransacRons ACID = Atomicity ( = recovery) Consistency IsolaRon ( = concurrency control) Durability 25
26 Client/Server Database Architecture Single server that stores the database Many clients running apps and connecrng to DBMS Performance boslenecks: Client/server communicaron TransacRonal semanrcs Other architectures: main memory database replicated databases 26
27 Two Types of Database Usage OLTP (online- transacron- processing) Many updates Many simple point queries Few (or no) complex aggregate queries Decision- Support Many aggregate/group- by queries. Few (or no) updates 27
28 Trends in Data Management Large scale data analyrcs: Map/Reduce, Pig, Cloud based database service: AWS, Azure, NoSQL: sacrifice ACID for performance Data privacy Data provenance Complex data analyrcs: probabilisrc databases 28
29 Outline of Course Content 1. SQL 2. RelaRonal Calculus, Database Design 3. Constraints, Views 4. TransacRons: recovery 5. TransacRons: concurrency control 6. XML, XPath, XQuery 7. Data storage, indexes, physical tuning 8. Query execuron 9. Query oprmizaron 10. Big Data: Parallel databases, Map/Reduce, Pig LaRn 11. Advanced topics: privacy, provenance, probabilisrc dbs 29
30 Announcement: Homework 1 Homework 1 is posted; Due on Monday, Oct. 10 Tools: Postgres: install on your computer (PREFERRED) or use the installaron in the lab SQL Server, for tesrng only; connect to IPROJSRV: login: your UW address; password:.. Tasks: create db, import data, create indices, write 11 SQL queries 30
31 Outline for rest of today Basics SQL (Chapters 5.2, 5.3) Aggregates (Chapter 5.5.) Nulls, Outer joins (Chapter 5.6) Subqueries (Chapters 5.4) This is tough! Next lecture we will discuss RelaRonal Calculus (a.k.a. Tuple Calculus, Chapter 4.3). See supplementary text Three Query Language Formalisms 31
32 SQL Data DefiniRon Language (DDL) Create/alter/delete tables and their asributes Read from the book Data ManipulaRon Language (DML) Query tables, Insert/delete/modify Discussed in class 32
33 Table name Tables in SQL Attribute names Product Key PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi Tuples or rows 33
34 The RelaRonal Data Model Data is stored in tables, a.k.a. relabons Each relaron has: 1. A schema = name+asributes Product(PName, Price, Category, Manufacturer) Each relaron has a key, which we underline 2. An instance = set of rows SQL departs from the pure relaronal model in that it allows duplicate tuples Set semanbcs à bag semanbcs {1, 2, 3} à {1, 1, 2, 3, 3, 3} 34
35 Data Types in SQL Atomic types: Characters: CHAR(20), VARCHAR(50) Numbers: INT, BIGINT, SMALLINT, FLOAT Others: MONEY, DATETIME, Record (aka tuple) Has atomic asributes Table (relaron) A set of tuples 35
36 Simple SQL Query Product PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi SELECT * FROM Product WHERE category= Gadgets selection PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks 36
37 Simple SQL Query Product PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi SELECT PName, Price, Manufacturer FROM Product WHERE Price > $100 selection and projection PName Price Manufacturer SingleTouch $ Canon MultiTouch $ Hitachi 37
38 Details Case insensirve: SELECT = Select = select Product = product BUT: SeaSle seasle Constants: abc - yes abc - no 38
39 EliminaRng Duplicates SELECT DISTINCT category FROM Product Category Gadgets Photography Household Compare to: SELECT category FROM Product Category Gadgets Gadgets Photography Household 39
40 Ordering the Results SELECT pname, price, manufacturer FROM Product WHERE category= Gadgets AND price > $10 ORDER BY price, pname Ties are broken by the second attribute on the ORDER BY list. Ordering is ascending, unless you specify the DESC keyword. 40
41 PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi SELECT DISTINCT category FROM Product ORDER BY category SELECT Category FROM Product ORDER BY PName?? SELECT DISTINCT category FROM Product ORDER BY PName? 41
42 Keys and Foreign Keys Company Key Product CName GizmoWorks Canon Hitachi Country USA Japan Japan PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi Foreign key 42
43 Joins Product (PName, Price, Category, Manufacturer) Company (CName,, Country) Find all products under $200 manufactured in Japan; return their names and prices. Join between Product and Company SELECT PName, Price FROM Product, Company WHERE Manufacturer=CName AND Country= Japan AND Price <= $200 43
44 Joins Product PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi Company Cname GizmoWorks Canon Hitachi Country USA Japan Japan SELECT PName, Price FROM Product, Company WHERE Manufacturer=CName AND Country= Japan AND Price <= $200 PName Price SingleTouch $
45 Tuple Variables Product (PName, Price, Category, Manufacturer) Company (CName,, Country) Person(name, Country, Worksfor) SELECT DISTINCT name, country FROM Person, Company WHERE worksfor = cname Which country? SELECT DISTINCT Person.name, Company.country FROM Person, Company WHERE Person.worksfor = Company.cname SELECT DISTINCT x.name, y.country FROM Person AS x, Company AS y WHERE x.worksfor Dan Suciu = y.cname -- p544 Fall
46 In Class Product (pname, price, category, manufacturer) Company (cname, country) Find all Chinese companies that manufacture products in the toy category SELECT cname FROM WHERE 46
47 In Class Product (pname, price, category, manufacturer) Company (cname, country) Find all Chinese companies that manufacture products both in the electronic and toy categories SELECT cname FROM WHERE 47
48 The Nested Loop SemanRcs of SQL Queries SELECT a 1, a 2,, a k FROM R 1 AS x 1, R 2 AS x 2,, R n AS x n WHERE CondiRons Answer = {} for x 1 in R 1 do for x 2 in R 2 do.. for x n in R n do if Conditions then Answer = Answer {(a 1,,a k )} return Answer 48
49 Using the Formal SemanRcs What do these queries compute? SELECT DISTINCT R.A FROM R, S WHERE R.A=S.A Returns R S SELECT DISTINCT R.A FROM R, S, T WHERE R.A=S.A OR R.A=T.A If S and T then returns R (S T) else returns 49
50 AggregaRon Product (pname, price, category, manufacturer) Company (cname, country) SELECT count(*) FROM Product SELECT sum(price) FROM Product WHERE manufacturer= GizmoWorks SQL supports several aggregation operations: sum, count, min, max, avg Except count, all aggregations apply to a single attribute 50
51 AggregaRon: Count Product (pname, price, category, manufacturer) Company (cname, country) COUNT applies to duplicates, unless otherwise stated: SELECT count(category) FROM Product WHERE price > $20 If category has no nulls, then count(category)=count(*) We probably want: SELECT count(distinct category) FROM Product WHERE price > $20 51
52 Grouping and AggregaRon Product (pname, price, category, manufacturer) Company (cname, country) For each manufacturer, find total number of its products under $200. SELECT manufacturer, count(*) AS total FROM Product WHERE price < $200 GROUP BY manufacturer Let s see what this means 52
53 Grouping and AggregaRon 1. Compute the FROM and WHERE clauses. 2. Group by the attributes in the GROUPBY 3. Compute the SELECT clause, including aggregates. 53
54 SELECT manufacturer, count(*) AS total FROM Product WHERE price < $200 GROUP BY manufacturer 1&2. FROM- WHERE- GROUPBY PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi 54
55 3. SELECT SELECT manufacturer, count(*) AS total FROM Product WHERE price < $200 GROUP BY manufacturer PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi count(*) Manufacturer 2 GizmoWorks 1 Canon 55
56 HAVING Clause Product (pname, price, category, manufacturer) Company (cname, country) Same query, except that we return only those manufacturers that make only products with price > $20 SELECT manufacturer, count(*) AS total FROM Product WHERE price < $200 GROUP BY manufacturer HAVING min(price) > $20 HAVING clause contains conditions on aggregates. 56
57 General form of Grouping and AggregaRon SELECT S FROM R 1,,R n WHERE C1 GROUP BY a 1,,a k HAVING C2 Why? S = may contain asributes a 1,,a k and/or any aggregates but NO OTHER ATTRIBUTES C1 = is any condiron on the asributes in R 1,,R n C2 = is any condiron on aggregate expressions 57
58 General form of Grouping and AggregaRon SELECT FROM WHERE S R 1,,R n C1 GROUP BY a 1,,a k HAVING C2 EvaluaRon steps: 1. Evaluate FROM- WHERE, apply condiron C1 2. Group by the asributes a 1,,a k 3. Apply condiron C2 to each group (may have aggregates) 4. Compute aggregates in S and return the result 58
59 NULLS in SQL Whenever we don t have a value, we can put a NULL Can mean many things: Value does not exists Value exists but is unknown Value not applicable Etc. The schema specifies for each asribute if can be null (nullable asribute) or not How does SQL cope with tables that have NULLs? 59
60 Null Values If x= NULL then 4*(3- x)/7 is srll NULL If x= NULL then x= Joe is UNKNOWN In SQL there are three boolean values: FALSE = 0 UNKNOWN = 0.5 TRUE = 1 60
61 Null Values C1 AND C2 = min(c1, C2) C1 OR C2 = max(c1, C2) NOT C1 = 1 C1 SELECT * FROM Person WHERE (age < 25) AND (height > 6 OR weight > 190) E.g. age=20 heigth=null weight=200 Rule in SQL: include only tuples that yield TRUE 61
62 Null Values Unexpected behavior: SELECT * FROM Person WHERE age < 25 OR age >= 25 Some Persons are not included! 62
63 Null Values Can test for NULL explicitly: x IS NULL x IS NOT NULL SELECT * FROM Person WHERE age < 25 OR age >= 25 OR age IS NULL Now it includes all Persons 63
64 Outerjoins Product (pname, price, category, manufacturer) Company (cname, country) Normally, joins are inner joins : Same as: SELECT x.country, y.pname FROM Company x, Product y WHERE x.cname = y.manufacturer SELECT x.country, y.pname FROM Company x JOIN Product y ON x.cname = y.manufacturer But countries that don t manufacture will not be listed! 64
65 Outerjoins Product (pname, price, category, manufacturer) Company (cname, country) If we want to see the companies that don t produce anything, then we use an outer join: SELECT x.country, y.pname FROM Company x LEFT OUTER JOIN Product y ON x.cname = y.manufacturer 65
66 Company Cname GizmoWorks Canon Hitachi MuseumPass Country USA Japan Japan Vatican Product PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $ Photography Canon MultiTouch $ Household Hitachi Cname USA USA Japan Japan Vatican PName GizmoWorks GizmoWorks Canon Hitachi NULL 66
67 ApplicaRon Product (pname, price, category, manufacturer) Company (cname, country) Compute the total number of products made by each country SELECT x.country, count(*) FROM Company x, Product y WHERE x.cname = y.manufacturer GROUP BY x.country What s wrong? 67
68 ApplicaRon Product (pname, price, category, manufacturer) Company (cname, country) Compute the total number of products made by each country Note: we don t use count(*) WHY? SELECT x.country, count(y.pname) FROM Company x LEFT OUTER JOIN Product y ON x.cname = y.manufacturer GROUP BY x.country Now we also get the products who sold in 0 quantity 68
69 Outer Joins Leh outer join: Include the leh tuple even if there s no match Right outer join: Include the right tuple even if there s no match Full outer join: Include the both leh and right tuples even if there s no match 69
70 Subqueries A subquery is another SQL query nested inside a larger query Such inner- outer queries are called nested queries A subquery may occur in: 1. A SELECT clause 2. A FROM clause 3. A WHERE clause Rule of thumb: avoid wrirng nested queries when possible; somermes it s impossible 70
71 1. Subqueries in SELECT Product (pname, price, category, manufacturer) Company (cname, country) For each product return the country that manufactures it SELECT X.pname, (SELECT Y.country FROM Company Y WHERE Y.cname=X.manufacturer) FROM Product X What happens if a subquery returns more than one country? 71
72 1. Subqueries in SELECT Product (pname, price, category, manufacturer) Company (cname, country) Whenever possible, don t use a nested queries: SELECT X.pname, (SELECT Y.country FROM Company Y WHERE Y.cname=X.manufacturer) FROM Product X = We have unnested the query SELECT pname, country FROM Product, Company WHERE cname=manufacturer 72
73 1. Subqueries in SELECT Product (pname, price, category, manufacturer) Company (cname, country) Compute the number of products made by each country SELECT DISTINCT x.country, (SELECT count(*) FROM Company y, Product WHERE y.cname=manufacturer and y.country = x.country) FROM Company x Better: we can unnest by using a GROUP BY SELECT x.country, count(*) FROM Company x, Product z WHERE x.cname = z.manufacturer GROUP BY x.country 73
74 GROUP BY v.s. Nested Quereis SELECT manufacturer, count(*) AS total FROM Product WHERE price < '$200 GROUP BY manufacturer SELECT DISTINCT x.manufacturer, (SELECT count(*) FROM Product y WHERE x.manufacturer = y.manufacturer AND price < '$200 ) AS total FROM Product x WHERE price < '$200 Why twice? 74
75 2. Subqueries in FROM Product (pname, price, category, manufacturer) Company (cname, country) Find all products whose prices is > 20 and < 30 SELECT * FROM (SELECT * FROM Product AS Y WHERE Y.price > $20 ) AS x WHERE x.price < $30 Unnest this query! 75
76 3. Subqueries in WHERE Existential quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find all countries that make some products with price < 100 Using EXISTS: Correlated subqery: uses x from outer query SELECT DISTINCT x.country FROM Company x WHERE EXISTS (SELECT * FROM Product y WHERE y.manufacturer = x.cname and y.price < $100 ) 76
77 3. Subqueries in WHERE Existential quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find all countries that make some products with price < 100 Predicate Calculus (a.k.a. First Order Logic) { y x.company(x,y) ( z. p. c.product(z,p,c,x) p<100)} 77
78 3. Subqueries in WHERE Existential quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find all countries that make some products with price < 100 Using IN SELECT DISTINCT country FROM Company WHERE cname IN (SELECT Product.manufacturer FROM Product WHERE Product.price < $100 ) De- correlated subqery 78
79 3. Subqueries in WHERE Existential quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find all countries that make some products with price < 100 Using ANY: SELECT DISTINCT Company.country FROM Company WHERE $100 > ANY (SELECT price FROM Product WHERE manufacturer = cname) 79
80 3. Subqueries in WHERE Existential quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find all countries that make some products with price < 100 Now let s unnest it: SELECT DISTINCT x.country FROM Company x, Product y WHERE x.cname = y.manufacturer and y.price < $100 Existential quantifiers are easy! J 80
81 3. Subqueries in WHERE Universal quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find the countries of all companies that make only products with price < 100 Universal quantifiers are hard! L 81
82 3. Subqueries in WHERE Universal quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find the countries of all companies that make only products with price < 100 Predicate Calculus (a.k.a. First Order Logic) { y x.company(x,y) ( z. p. c.product(z,p,c,x)è p<100) } 82
83 3. Subqueries in WHERE De Morgan s Laws: (A B) = A B (A B) = A B x. P(x) = x. P(x) x. P(x) = x. P(x) (A è B) = A B { y x. Company(x,y) ( z. p. c.product(z,p,c,x)è p<100) } = { y x.company(x,y) ( z p. p.product(z,p,c,x) p 100) } = { y x. Company(x,y)) } { y x. Company(x,y) ( z p. c.product(z,p,c,x) p 100) 83 }
84 3. Subqueries in WHERE 1. Find the other companies: i.e. s.t. some product 100 SELECT DISTINCT country FROM Company WHERE cname IN (SELECT manufacturer FROM Product WHERE price >= $100 ) 2. Find all companies s.t. all their products have price < 100 SELECT DISTINCT country FROM Company WHERE cname NOT IN (SELECT manufacturer FROM Product WHERE price >= $100 ) 84
85 3. Subqueries in WHERE Universal quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find the countries of all companies that make only products with price < 100 Using EXISTS: SELECT DISTINCT x.country FROM Company x WHERE NOT EXISTS (SELECT * FROM Product y WHERE y.manufacturer = x.cname and y.price >= $100 ) 85
86 3. Subqueries in WHERE Universal quantifiers Product (pname, price, category, manufacturer) Company (cname, country) Find the countries of all companies that make only products with price < 100 Using ALL: SELECT DISTINCT Company.country FROM Company WHERE $100 > ALL (SELECT price FROM Product WHERE manufacturer = cname) 86
87 QuesRon for Database Fans and their Friends Find the countries of all companies that make only products with price < 100 Can we unnest this query? 87
88 Monotone Queries A query Q is monotone if: Whenever we add tuples to one or more of the tables the answer to the query cannot contain fewer tuples Fact: all unnested queries are monotone Proof: using the nested for loops semanrcs Fact: A query a universal quanrfier is not monotone Consequence: we cannot unnest a query with a universal quanrfier 88
89 Queries that must be nested Rule of Thumb: Non- monotone queries cannot be unnested. In parrcular, queries with a universal quanrfier cannot be unnested 89
90 More SQL Read the following commands in the book CREATE TABLE INSERT DELETE UPDATE They are easy; but we need/use them all the Rme in class, and in the homework assignments 90
91 Advanced SQLizing 1. UnnesRng Aggregates 2. Finding witnesses 91
92 UnnesRng Aggregates Product (pname, price, category, manufacturer) Company (cname, country) For each category, find the maximum price SELECT DISTINCT X.category, (SELECT max(y.price) FROM Product Y WHERE X.category = Y.category) FROM Product X SELECT category, max(price) FROM Product GROUP BY category Equivalent queries Note: no need for DISTINCT (DISTINCT is the same as GROUP BY)
93 UnnesRng Aggregates Product (pname, price, category, manufacturer) Company (cname, country) Find the number of products made in each country SELECT DISTINCT X.country, (SELECT count(*) FROM Company Y, Product Z WHERE Y.cname=Z.manufacturer AND Y.country = X.country) FROM Company X SELECT X.country, count(*) FROM Company X, Product Y WHERE X.cname=Y.manufacturer GROUP BY X.country They are NOT equivalent! (WHY?)
94 Author(login,name) Wrote(login,url) More UnnesRng Find authors who wrote 10 documents: ASempt 1: with nested queries SELECT DISTINCT Author.name FROM Author WHERE This is SQL by a novice count(select Wrote.url FROM Wrote WHERE Author.login=Wrote.login) > 10 94
95 More UnnesRng Find all authors who wrote at least 10 documents: ASempt 2: SQL style (with GROUP BY) SELECT DISTINCT Author.name FROM Author, Wrote WHERE Author.login=Wrote.login GROUP BY Author.name HAVING count(wrote.url) > 10 This is SQL by an expert 95
96 Finding Witnesses Product (pname, price, category, manufacturer) Company (cname, country) For each country, find its most expensive products 96
97 Finding Witnesses Product (pname, price, category, manufacturer) Company (cname, country) For each country, find its most expensive products Finding the maximum price is easy SELECT x.country, max(y.price) FROM Company x, Product y WHERE x.cname = y.manufacturer GROUP BY x.country But we need the witnesses, i.e. the products with max price
98 Finding Witnesses To find the witnesses, compute the maximum price in a subquery SELECT u.country, v.pname, v.price FROM Company u, Product v, (SELECT x.country, max(y.price) as mprice FROM Company x, Product y WHERE x.cname = y.manufacturer GROUP BY x.country) AS p WHERE u.country = p.country and v.price = p.mprice 98
99 Finding Witnesses Product (pname, price, category, manufacturer) Company (cname, country) There is a more concise solution here: SELECT x.country, y.pname, y.price FROM Company x, Product y WHERE x.cname = y.manufacturer and y.price >= ALL (SELECT z.price FROM Product z WHERE x.cname = z.manufacturer) 99
Principles of Database Systems CSE 544. Lecture #2 SQL The Complete Story
Principles of Database Systems CSE 544 Lecture #2 SQL The Complete Story CSE544 - Spring, 2013 1 Announcements Paper assignment Review was due last night Discussion on Thursday We need to schedule a makeup
More informationPrinciples of Database Systems CSE 544. Lecture #1 Introduction and SQL
Principles of Database Systems CSE 544 Lecture #1 Introduction and SQL 1 Staff Instructor: Dan Suciu CSE 662, suciu@cs.washington.edu Office hour: Wednesdays, 1:30-2:20, CSE 662 TA: Paris Koutris, pkoutris@cs.washington.edu
More informationIntroduc)on to Database Systems CSE 444. Lecture #1 March 29, 2010
Introduc)on to Database Systems CSE 444 Lecture #1 March 29, 2010 1 Staff Instructor: Dan Suciu CSE 662, suciu@cs.washington.edu Office hours: Mondays 1:30 2:30 Grad TA: Jessica Leung joyleung@cs.washington.edu
More informationSQL. Structured Query Language
SQL Structured Query Language SQL Data Definition Language (DDL) Create/alter/delete tables and their attributes We won t cover this... Data Manipulation Language (DML) Query one or more tables discussed
More informationPrinciples of Database Systems CSE 544. Lecture #1 Introduction and SQL
Principles of Database Systems CSE 544 Lecture #1 Introduction and SQL CSE544 - Spring, 2013 1 Staff Instructor: Dan Suciu CSE 662, suciu@cs.washington.edu Office hour: Wednesdays, 1:30-2:20, CSE 662 TA:
More informationIntroduction to Database Systems CSE 444
Introduction to Database Systems CSE 444 Lecture 2: SQL Announcements Project 1 & Hw 1 are posted on class website Project 1 (SQL) due in two weeks Homework 1 (E/R models etc) due in three weeks Remember:
More informationIntroduction to Database S ystems Systems CSE 444 Lecture 1 Introduction CSE Summer
Introduction to Database Systems CSE 444 Lecture 1 Introduction 1 Staff Instructor: Hal Perkins CSE 548, perkins@cs.washington.edu Office hours: labs tba, office drop-ins and appointments welcome TA: David
More informationIntroduction to Database S ystems Systems CSE 444 Lecture 1 Introduction CSE Summer
Introduction to Database Systems CSE 444 Lecture 1 Introduction 1 Staff Instructor: Hal Perkins CSE 548, perkins@cs.washington.edu Office hours: CSE labs tba, office drop-ins and appointments welcome TA:
More informationIntroduction to Database Systems CSE 444. Lecture 1 Introduction
Introduction to Database Systems CSE 444 Lecture 1 Introduction 1 About Me: General Prof. Magdalena Balazinska (magda) At UW since January 2006 PhD from MIT Born in Poland Grew-up in Poland, Algeria, and
More informationLecture 03: SQL. Friday, April 2 nd, Dan Suciu Spring
Lecture 03: SQL Friday, April 2 nd, 2010 Dan Suciu -- 444 Spring 2010 1 Announcements New IMDB database: use imdb_new instead of imdb Up to date, and much larger! Make following change to Project 1 / QuesMon
More informationIntroduction to Database Systems CSE 444. Lecture #1 March 26, 2007
Introduction to Database Systems CSE 444 Lecture #1 March 26, 2007 1 About Me Dan Suciu: Joined the department in 2000 Before that: Bell Labs, AT&T Labs Research: Past: XML and semi-structured data: Query
More informationIntroduction to Data Management CSE 344
Introduction to Data Management CSE 344 Lectures 4 and 5: Aggregates in SQL Dan Suciu - CSE 344, Winter 2012 1 Announcements Homework 1 is due tonight! Quiz 1 due Saturday Homework 2 is posted (due next
More informationSQL. Assit.Prof Dr. Anantakul Intarapadung
SQL Assit.Prof Dr. Anantakul Intarapadung SQL Introduction SQL (Structured Query Language) เป นภาษามาตรฐานท ใช สาหร บการเร ยกด ข อม ล (querying )และบร หาร จ ดการข อม ล ภาษาน ถ กพ ฒนามาหลากหลายเวอร ช น
More informationLecture 2: Introduction to SQL
Lecture 2: Introduction to SQL Lecture 2 Announcements! 1. If you still have Jupyter trouble, let us know! 2. Enroll to Piazza!!! 3. People are looking for groups. Team up! 4. Enrollment should be finalized
More informationIntroduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)
Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Lecture 2 Lecture Overview 1. SQL introduction & schema definitions 2. Basic single-table queries
More informationAgenda. Discussion. Database/Relation/Tuple. Schema. Instance. CSE 444: Database Internals. Review Relational Model
Agenda CSE 444: Database Internals Review Relational Model Lecture 2 Review of the Relational Model Review Queries (will skip most slides) Relational Algebra SQL Review translation SQL à RA Needed for
More informationPolls on Piazza. Open for 2 days Outline today: Next time: "witnesses" (traditionally students find this topic the most difficult)
L04: SQL 124 Announcements! Polls on Piazza. Open for 2 days Outline today: - practicing more joins and specifying key and FK constraints - nested queries Next time: "witnesses" (traditionally students
More informationAnnouncements. Agenda. Database/Relation/Tuple. Discussion. Schema. CSE 444: Database Internals. Room change: Lab 1 part 1 is due on Monday
Announcements CSE 444: Database Internals Lecture 2 Review of the Relational Model Room change: Gowen (GWN) 301 on Monday, Friday Fisheries (FSH) 102 on Wednesday Lab 1 part 1 is due on Monday HW1 is due
More informationBig Data Processing Technologies. Chentao Wu Associate Professor Dept. of Computer Science and Engineering
Big Data Processing Technologies Chentao Wu Associate Professor Dept. of Computer Science and Engineering wuct@cs.sjtu.edu.cn Schedule (1) Storage system part (first eight weeks) lec1: Introduction on
More informationDS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)
DS 1300 - Introduction to SQL Part 1 Single-Table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Overview 1. SQL introduction & schema definitions 2. Basic single-table
More informationAnnouncements. Agenda. Database/Relation/Tuple. Schema. Discussion. CSE 444: Database Internals
Announcements CSE 444: Database Internals Lecture 2 Review of the Relational Model Lab 1 part 1 is due on Friday Lab 1 is due next week on Friday git commit a and git push often! HW1 is due on Wednesday,
More informationCSE 544 Principles of Database Management Systems
CSE 544 Principles of Database Management Systems Magdalena Balazinska Winter 2015 Lecture 2 SQL and Schema Normalization 1 Announcements Paper review First paper review is due before lecture on Wednesday
More informationLecture 3: SQL Part II
Lecture 3 Lecture 3: SQL Part II Copyright: These slides are the modified version of the slides used in CS145 Introduction to Databases course at Stanford by Dr. Peter Bailis Lecture 3 Today s Lecture
More informationIntroduction to Data Management CSE 344
Introduction to Data Management CSE 344 Lecture 4: Joins and Aggregates CSE 344 - Fall 2016 1 Announcements HW1 is due tonight at 11pm WQ2 is out HW2 is out Write queries using real-world dataset Due in
More informationDatabase Systems CSE 414
Database Systems CSE 414 Lectures 4: Joins & Aggregation (Ch. 6.1-6.4) 1 Announcements Should now have seats for all registered 2 Outline Inner joins (6.2, review) Outer joins (6.3.8) Aggregations (6.4.3
More informationCSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2006 Lecture 3 - Relational Model
CSE 544 Principles of Database Management Systems Magdalena Balazinska Fall 2006 Lecture 3 - Relational Model References E.F. Codd. A relational model of data for large shared data banks. Communications
More informationLectures 2&3: Introduction to SQL
Lectures 2&3: Introduction to SQL Lecture 2 Announcements! 1. If you still have Jupyter trouble, let us know! 2. Problem Set #1 is released! 2 Lecture 2 Lecture 2: SQL Part I Lecture 2 Today s Lecture
More informationCSC 261/461 Database Systems Lecture 5. Fall 2017
CSC 261/461 Database Systems Lecture 5 Fall 2017 MULTISET OPERATIONS IN SQL 2 UNION SELECT R.A FROM R, S WHERE R.A=S.A UNION SELECT R.A FROM R, T WHERE R.A=T.A Q 1 Q 2 r. A r. A = s. A r. A r. A = t. A}
More informationAnnouncements. Outline UNIQUE. (Inner) joins. (Inner) Joins. Database Systems CSE 414. WQ1 is posted to gradebook double check scores
Announcements Database Systems CSE 414 Lectures 4: Joins & Aggregation (Ch. 6.1-6.4) WQ1 is posted to gradebook double check scores WQ2 is out due next Sunday HW1 is due Tuesday (tomorrow), 11pm HW2 is
More informationIntroduction to Database Systems CSE 414. Lecture 8: SQL Wrap-up
Introduction to Database Systems CSE 414 Lecture 8: SQL Wrap-up CSE 414 - Spring 2015 1 Announcements New web quiz out: due Monday, 11 pm A couple of questions on nested queries Homework 3 out today and
More informationCSE 544 Principles of Database Management Systems
CSE 544 Principles of Database Management Systems Alvin Cheung Fall 2015 Lecture 2 SQL and Schema Normalization 1 Announcements Paper review First paper review is due on Wednesday 10:30am Details on website
More informationLecture 4: Advanced SQL Part II
Lecture 4: Advanced SQL Part II Lecture 4 Announcements! 1. Problem Set #1 is released! We will discuss some of the questions at the end of this lecture 2. Project group assignments Does everybody have
More informationIntroduction to Database Systems CSE 414
Introduction to Database Systems CSE 414 Lectures 4 and 5: Aggregates in SQL CSE 414 - Spring 2013 1 Announcements Homework 1 is due on Wednesday Quiz 2 will be out today and due on Friday CSE 414 - Spring
More informationDS Introduction to SQL Part 2 Multi-table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)
DS 1300 - Introduction to SQL Part 2 Multi-table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) What you will learn about in this section 1. Foreign key constraints
More informationDatabase Systems CSE 414
Database Systems CSE 414 Lecture 6: Nested Queries in SQL 1 Announcements WQ2 is due on Sunday 11pm no late days HW2 is due on Tuesday 11pm 2 Lecture Goals Today we will learn how to write (even) more
More informationLecture 04: SQL. Monday, April 2, 2007
Lecture 04: SQL Monday, April 2, 2007 1 Outline The Project Nulls (6.1.6) Outer joins (6.3.8) Database Modifications (6.5) 2 NULLS in SQL Whenever we don t have a value, we can put a NULL Can mean many
More informationLecture 04: SQL. Wednesday, October 4, 2006
Lecture 04: SQL Wednesday, October 4, 2006 1 Outline The Project Nulls (6.1.6) Outer joins (6.3.8) Database Modifications (6.5) 2 The Project Application: Boutique online music and book store Project:
More informationAnnouncements. Subqueries. Lecture Goals. 1. Subqueries in SELECT. Database Systems CSE 414. HW1 is due today 11pm. WQ1 is due tomorrow 11pm
Announcements Database Systems CSE 414 Lecture 6: Nested Queries in SQL HW1 is due today 11pm WQ1 is due tomorrow 11pm no late days WQ3 is posted and due on Oct. 19, 11pm 1 2 Lecture Goals Today we will
More informationIntroduction to Databases CSE 414. Lecture 2: Data Models
Introduction to Databases CSE 414 Lecture 2: Data Models CSE 414 - Autumn 2018 1 Class Overview Unit 1: Intro Unit 2: Relational Data Models and Query Languages Data models, SQL, Relational Algebra, Datalog
More informationCSE 344 JANUARY 5 TH INTRO TO THE RELATIONAL DATABASE
CSE 344 JANUARY 5 TH INTRO TO THE RELATIONAL DATABASE ADMINISTRATIVE MINUTIAE Midterm Exam: February 9 th : 3:30-4:20 Final Exam: March 15 th : 2:30 4:20 ADMINISTRATIVE MINUTIAE Midterm Exam: February
More informationIntroduction to Relational Databases
Introduction to Relational Databases Adopted from slides by Prof. Dan Suciu, University of Washington - Seattle - Paul G. Allen School of Computer Science & Engineering 1 What Is a Relational Database
More informationIntroduction to Database Systems CSE 414
Introduction to Database Systems CSE 414 Lecture 8: Nested Queries in SQL CSE 414 - Spring 2013 1 Announcements Homework 2 due tonight Webquiz 3 due Friday 2 questions on nested queries (i.e., today s
More informationIntroduction to Database Systems
Introduction to Database Systems Based on slides by Dan Suciu Adapted by Michael Hahsler 1 / 16 Database What is a database? Physical storage: A collection of files storing related data. Logical: A collection
More informationIntroduction to Database Systems CSE 414. Lecture 3: SQL Basics
Introduction to Database Systems CSE 414 Lecture 3: SQL Basics CSE 414 - Spring 2018 1 Review Relational data model Schema + instance + query language Query language: SQL Create tables Retrieve records
More informationBefore we talk about Big Data. Lets talk about not-so-big data
Before we talk about Big Data Lets talk about not-so-big data Brief Intro to Database Systems Tova Milo, milo@cs.tau.ac.il 1 Textbook(s) Main textbook (In the library) Database Systems: The Complete Book,
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 informationIntroduction to Database Systems CSE 414. Lecture 3: SQL Basics
Introduction to Database Systems CSE 414 Lecture 3: SQL Basics CSE 414 - Autumn 2018 1 Review Relational data model Schema + instance + query language Query language: SQL Create tables Retrieve records
More informationIntroduction to Data Management CSE 344. Lecture 2: Data Models
Introduction to Data Management CSE 344 Lecture 2: Data Models CSE 344 - Winter 2017 1 Announcements WQ1 and HW1 are out Use your CSE ids to access the HW docs Use Piazza to post questions OHs are up on
More informationINF 212 ANALYSIS OF PROG. LANGS SQL AND SPREADSHEETS. Instructors: Crista Lopes Copyright Instructors.
INF 212 ANALYSIS OF PROG. LANGS SQL AND SPREADSHEETS Instructors: Crista Lopes Copyright Instructors. Data-Centric Programming Focus on data Interactive data: SQL Dataflow: Spreadsheets Dataflow: Iterators,
More informationSubqueries. 1. Subqueries in SELECT. 1. Subqueries in SELECT. Including Empty Groups. Simple Aggregations. Introduction to Database Systems CSE 414
Introduction to Database Systems CSE 414 Lecture 7: SL Wrapup CSE 414 - Spring 2018 1 Subqueries A subquery is a SL query nested inside a larger query Such inner-outer queries are called nested queries
More informationLecture 3 Additional Slides. CSE 344, Winter 2014 Sudeepa Roy
Lecture 3 dditional Slides CSE 344, Winter 014 Sudeepa Roy Note: These slides mostly contain the same material as the lecture notes, and were used as a substitute for a whiteboard in class. lso please
More informationIntroduction to SQL Part 2 by Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford)
Introduction to SQL Part 2 by Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford) Lecture 3 Lecture Overview 1. Aggregation & GROUP BY 2. Set operators & nested queries 3. Advanced
More informationIntroduction to Data Management CSE 344. Lecture 1: Introduction
Introduction to Data Management CSE 344 Lecture 1: Introduction CSE 344 - Winter 2014 1 Staff Instructor: Sudeepa Roy sudeepa@cs.washington.edu Office hours: Wednesdays, 3:30-4:20, in CSE 344 (my office)
More informationCSE 344 JANUARY 19 TH SUBQUERIES 2 AND RELATIONAL ALGEBRA
CSE 344 JANUARY 19 TH SUBQUERIES 2 AND RELATIONAL ALGEBRA ASSORTED MINUTIAE Winter storm Inga Online quiz out after class Still due Wednesday, will be shorter but through today s lecture For SQLite submissions,
More informationCSE 344 JANUARY 8 TH SQLITE AND JOINS
CSE 344 JANUARY 8 TH SQLITE AND JOINS ADMINISTRATIVE MINUTIAE Next Monday, MLK day HW1, and QZ1 due next Wednesday Online Quizzes Newgradiance.com Course token: B5B103B6 Code assignment Through gitlab
More informationCSE 303: Database. Teaching Staff. Lecture 01. Lectures: 1 st half - from a user s perspective. Lectures: 2 nd half - understanding how it works
CSE 303: Database Lecture 01 Instructors: Teaching Staff 2016 Introductory Lecture Ashikur Rahman Prof. ASM Latiful Hoque Office: CSE 117 Office: CSE 118 1 2 Lectures: 1 st half - from a user s perspective
More informationPrinciples of Database Systems CSE 544. Lecture #2 SQL, Relational Algebra, Relational Calculus
Principles of Database Systems CSE 544 Lecture #2 SQL, Relational Algebra, Relational Calculus CSE544 - Spring, 2012 1 Announcements Makeup: Friday, March 30, 11-12:30, Room TBD 1 st Paper review due (Answering
More informationDatabase design and implementation CMPSCI 645. Lecture 04: SQL and Datalog
Database design and implementation CMPSCI 645 Lecture 04: SQL and Datalog What you need } Install Postgres. } Instruc0ons are on the assignments page on the website. } Use it to prac0ce } Refresh your
More informationCS 2451 Database Systems: More SQL
CS 2451 Database Systems: More SQL http://www.seas.gwu.edu/~bhagiweb/cs2541 Spring 2019 Instructor: Dr. Bhagi Narahari & R. Leontie Today. Quick recap of basic SQL Advanced querying features Set membership,
More informationKeys, SQL, and Views CMPSCI 645
Keys, SQL, and Views CMPSCI 645 SQL Overview SQL Preliminaries Integrity constraints Query capabilities SELECT-FROM- WHERE blocks, Basic features, ordering, duplicates Set ops (union, intersect, except)
More informationSELECT Product.name, Purchase.store FROM Product JOIN Purchase ON Product.name = Purchase.prodName
Announcements Introduction to Data Management CSE 344 Lectures 5: More SQL aggregates Homework 2 has been released Web quiz 2 is also open Both due next week 1 2 Outline Outer joins (6.3.8, review) More
More informationPlease pick up your name card
L06: SQL 233 Announcements! Please pick up your name card - always come with your name card - If nobody answers my question, I will likely pick on those without a namecard or in the last row Polls on speed:
More informationDatabase Management Systems CSEP 544. Lecture 3: SQL Relational Algebra, and Datalog
Database Management Systems CSEP 544 Lecture 3: SQL Relational Algebra, and Datalog CSEP 544 - Fall 2017 1 Announcements HW2 due tonight (11:59pm) PA3 & HW3 released CSEP 544 - Fall 2017 2 HW3 We will
More informationDatabase Systems CSE 414
Database Systems CSE 414 Lecture 15-16: Basics of Data Storage and Indexes (Ch. 8.3-4, 14.1-1.7, & skim 14.2-3) 1 Announcements Midterm on Monday, November 6th, in class Allow 1 page of notes (both sides,
More informationIntroduction to Data Management CSE 414
Introduction to Data Management CSE 414 Lecture 3: More SQL (including most of Ch. 6.1-6.2) Overload: https://goo.gl/forms/2pfbteexg5l7wdc12 CSE 414 - Fall 2017 1 Announcements WQ2 will be posted tomorrow
More informationCS 564 Midterm Review
Midterm Review CS 564 Midterm Review The Best Of Collection (Master Tracks), Vol. 1 Midterm Review Announcements Midterm next Wednesday In class: roughly 70 minutes Come in 10 minutes earlier! Midterm
More informationAnnouncements. Using Electronics in Class. Review. Staff Instructor: Alvin Cheung Office hour on Wednesdays, 1-2pm. Class Overview
Announcements Introduction to Databases CSE 414 Lecture 2: Data Models HW1 and WQ1 released Both due next Tuesday Office hours start this week Sections tomorrow Make sure you sign up on piazza Please ask
More informationHW1 is due tonight HW2 groups are assigned. Outline today: - nested queries and witnesses - We start with a detailed example! - outer joins, nulls?
L05: SQL 183 Announcements! HW1 is due tonight HW2 groups are assigned Outline today: - nested queries and witnesses - We start with a detailed example! - outer joins, nulls? 184 Small IMDB schema (SQLite)
More informationL07: SQL: Advanced & Practice. CS3200 Database design (sp18 s2) 1/11/2018
L07: SQL: Advanced & Practice CS3200 Database design (sp18 s2) 1/11/2018 254 Announcements! Please pick up your name card - always bring it - move closer to the front HW3 will be again SQL - individual
More informationCSE 544 Principles of Database Management Systems
CSE 544 Principles of Database Management Systems Lecture 1 - Introduction and the Relational Model 1 Outline Introduction Class overview Why database management systems (DBMS)? The relational model 2
More informationQuerying Data with Transact SQL
Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including
More informationCMPT 354: Database System I. Lecture 1. Course Introduction
CMPT 354: Database System I Lecture 1. Course Introduction 1 Outline Motivation for studying this course Course admin and set up Overview of course topics 2 Trend 1: Data grows exponentially 1 ZB = 1,
More informationSQLite, Firefox, and our small IMDB movie database. CS3200 Database design (sp18 s2) Version 1/17/2018
SQLite, Firefox, and our small IMDB movie database CS3200 Database design (sp18 s2) Version 1/17/2018 1 Overview This document covers 2 issues: How to install SQLite manager in Firefox browser: - SQLite
More informationData Informatics. Seon Ho Kim, Ph.D.
Data Informatics Seon Ho Kim, Ph.D. seonkim@usc.edu NoSQL and Big Data Processing Database Relational Databases mainstay of business Web-based applications caused spikes Especially true for public-facing
More informationCOMP 430 Intro. to Database Systems
SELECT name FROM sqlite_master WHERE type='table' COMP 430 Intro. to Database Systems Single-table SQL Get clickers today! Slides use ideas from Chris Ré and Chris Jermaine. Clicker test Have you used
More information5/2/16. Announcements. NoSQL Motivation. The New Hipster: NoSQL. Serverless. What is the Problem? Database Systems CSE 414
Announcements Database Systems CSE 414 Lecture 16: NoSQL and JSon Current assignments: Homework 4 due tonight Web Quiz 6 due next Wednesday [There is no Web Quiz 5 Today s lecture: JSon The book covers
More informationDatabase Systems CSE 414
Database Systems CSE 414 Lecture 16: NoSQL and JSon CSE 414 - Spring 2016 1 Announcements Current assignments: Homework 4 due tonight Web Quiz 6 due next Wednesday [There is no Web Quiz 5] Today s lecture:
More informationAnnouncements. Multi-column Keys. Multi-column Keys. Multi-column Keys (3) Multi-column Keys (2) Introduction to Data Management CSE 414
Introduction to Data Management CSE 414 Lecture 3: More SQL (including most of Ch. 6.1-6.2) Announcements WQ2 will be posted tomorrow and due on Oct. 17, 11pm HW2 will be posted tomorrow and due on Oct.
More informationIn-class activities: Sep 25, 2017
In-class activities: Sep 25, 2017 Activities and group work this week function the same way as our previous activity. We recommend that you continue working with the same 3-person group. We suggest that
More informationCMPT 354: Database System I. Lecture 3. SQL Basics
CMPT 354: Database System I Lecture 3. SQL Basics 1 Announcements! About Piazza 97 enrolled (as of today) Posts are anonymous to classmates You should have started doing A1 Please come to office hours
More informationOutline. Databases and DBMS s. Recent Database Applications. Earlier Database Applications. CMPSCI445: Information Systems.
Outline CMPSCI445: Information Systems Overview of databases and DBMS s Course topics and requirements Yanlei Diao University of Massachusetts Amherst Databases and DBMS s Commercial DBMS s A database
More informationCOMP 430 Intro. to Database Systems
COMP 430 Intro. to Database Systems Multi-table SQL Get clickers today! Slides use ideas from Chris Ré and Chris Jermaine. The need for multiple tables Using a single table leads to repeating data Provides
More informationYour New App. Motivation. Data Management is Universal. Staff. Introduction to Data Management (Database Systems) CSE 414. Lecture 1: Introduction
Introduction to Data Management (Database Systems) CSE 414 Lecture 1: Introduction The world is drowning in data! LSST produces 30 TB of data per night Large Synoptic Survey Telescope 9 PB per year LHC
More informationOutline. Database Management Systems (DBMS) Database Management and Organization. IT420: Database Management and Organization
Outline IT420: Database Management and Organization Dr. Crăiniceanu Capt. Balazs www.cs.usna.edu/~adina/teaching/it420/spring2007 Class Survey Why Databases (DB)? A Problem DB Benefits In This Class? Admin
More informationCSE 344 JANUARY 3 RD - INTRODUCTION
CSE 344 JANUARY 3 RD - INTRODUCTION COURSE FORMAT Lectures Location: SIG 134 Please attend Sections: Content: exercises, tutorials, questions, new materials (occasionally) Locations: see web Please attend
More informationCourse Web Site. 445 Staff and Mailing Lists. Textbook. Databases and DBMS s. Outline. CMPSCI445: Information Systems. Yanlei Diao and Haopeng Zhang
Course Web Site CMPSCI445: Information Systems Yanlei Diao and Haopeng Zhang University of Massachusetts Amherst http://avid.cs.umass.edu/courses/445/s2015/ or http://www.cs.umass.edu/~yanlei à Teaching
More informationAnnouncements. Two Classes of Database Applications. Class Overview. NoSQL Motivation. RDBMS Review: Serverless
Introduction to Database Systems CSE 414 Lecture 11: NoSQL 1 HW 3 due Friday Announcements Upload data with DataGrip editor see message board Azure timeout for question 5: Try DataGrip or SQLite HW 2 Grades
More informationCMPT 354: Database System I. Lecture 2. Relational Model
CMPT 354: Database System I Lecture 2. Relational Model 1 Outline An overview of data models Basics of the Relational Model Define a relational schema in SQL 2 Outline An overview of data models Basics
More informationCGS 3066: Spring 2017 SQL Reference
CGS 3066: Spring 2017 SQL Reference Can also be used as a study guide. Only covers topics discussed in class. This is by no means a complete guide to SQL. Database accounts are being set up for all students
More informationMTAT Introduction to Databases
MTAT.03.105 Introduction to Databases Lecture #3 Data Types, Default values, Constraints Ljubov Jaanuska (ljubov.jaanuska@ut.ee) Lecture 1. Summary SQL stands for Structured Query Language SQL is a standard
More informationIntroduction to Data Management (Database Systems) CSE 414
Introduction to Data Management (Database Systems) CSE 414 Lecture 1: Introduction Overload: https://catalyst.uw.edu/webq/survey/cseadv/328147 (fill this out by Wednesday evening) CSE 414 - Spring 2017
More informationCMPSCI445: Information Systems
CMPSCI445: Information Systems Yanlei Diao and Haopeng Zhang University of Massachusetts Amherst Course Web Site http://avid.cs.umass.edu/courses/445/s2015/ or http://www.cs.umass.edu/~yanlei à Teaching
More informationCSE 344 APRIL 16 TH SEMI-STRUCTURED DATA
CSE 344 APRIL 16 TH SEMI-STRUCTURED DATA ADMINISTRATIVE MINUTIAE HW3 due Wednesday OQ4 due Wednesday HW4 out Wednesday (Datalog) Exam May 9th 9:30-10:20 WHERE WE ARE So far we have studied the relational
More informationCompSci 516 Database Systems. Lecture 2 SQL. Instructor: Sudeepa Roy
CompSci 516 Database Systems Lecture 2 SQL Instructor: Sudeepa Roy Duke CS, Fall 2018 1 Announcements If you are enrolled to the class, but have not received the email from Piazza, please send me an email
More informationLecture 2 SQL. Announcements. Recap: Lecture 1. Today s topic. Semi-structured Data and XML. XML: an overview 8/30/17. Instructor: Sudeepa Roy
Announcements CompSci 516 Data Intensive Computing Systems Lecture 2 SQL Instructor: Sudeepa Roy If you are enrolled to the class, but have not received the email from Piazza, please send me an email All
More informationLecture 3 SQL - 2. Today s topic. Recap: Lecture 2. Basic SQL Query. Conceptual Evaluation Strategy 9/3/17. Instructor: Sudeepa Roy
CompSci 516 Data Intensive Computing Systems Lecture 3 SQL - 2 Instructor: Sudeepa Roy Announcements HW1 reminder: Due on 09/21 (Thurs), 11:55 pm, no late days Project proposal reminder: Due on 09/20 (Wed),
More informationAnnouncements. Multi-column Keys. Multi-column Keys (3) Multi-column Keys. Multi-column Keys (2) Introduction to Data Management CSE 414
Introduction to Data Management CSE 414 Announcements Reminder: first web quiz due Sunday Lecture 3: More SQL (including most of Ch. 6.1-6.2) CSE 414 - Spring 2017 1 CSE 414 - Spring 2017 2 Multi-column
More informationClass Overview. Two Classes of Database Applications. NoSQL Motivation. RDBMS Review: Client-Server. RDBMS Review: Serverless
Introduction to Database Systems CSE 414 Lecture 12: NoSQL 1 Class Overview Unit 1: Intro Unit 2: Relational Data Models and Query Languages Unit 3: Non-relational data NoSQL Json SQL++ Unit 4: RDMBS internals
More informationToday s topics. Null Values. Nulls and Views in SQL. Standard Boolean 2-valued logic 9/5/17. 2-valued logic does not work for nulls
Today s topics CompSci 516 Data Intensive Computing Systems Lecture 4 Relational Algebra and Relational Calculus Instructor: Sudeepa Roy Finish NULLs and Views in SQL from Lecture 3 Relational Algebra
More information