Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Databases (2)

Similar presentations


Presentation on theme: "Introduction to Databases (2)"— Presentation transcript:

1 Introduction to Databases (2)
COP 6726: New Directions in Database Systems Introduction to Databases (2)

2 Critical Reading

3 Six questions for Critical Reading
What is the problem? Why is it important? Why is it challenging (or hard)? What are the limitations of the related work? What is the novelty? What are the contributions? What is the validation methodology?

4 1. What is the problem? What is the problem addressed in the paper?
Is it clearly stated? Does the author make the important issues clear?

5 2. Why is it important? Is the problem significant / relevant?
Is there any reason to care about the problem (practical applications / real world applications) and paper’s results? Is the problem new?

6 3. Why is it challenging? What is the difficulty of solving the problem? Computationally complex? (NP completeness?) Large search space? Hard to solve?

7 4. What are the limitations of the related work? What is the novelty?
Has the problem been solved before? Is this a trivial variation on or extension of previous results? Is the author aware of related and previous work, both recent and old? What are the assumptions and limitations of related work? Which limitation is solved in the paper? Critique an assumption that you believe is unreasonable. What is the impact of removing this unreasonable assumption on the solution proposed by the authors?

8 5. What are the contributions?
Is the problem the extension of the related work? Which part is extended? Is the problem new? What are the proposed approaches, algorithms, and ideas? Is there any experimental and analytical evaluation?

9 6. What is the validation methodology?
Case study? Statistical hypothesis testing? Analytical evaluation? Computational complexity? Theorem and lemmas, proofs? Experimental evaluation? The strengths and weaknesses of the methodology? Why did authors choose this/these methodology?

10 Paper & Presentation (20%)
Project (30%) Proposal (10%) Paper & Presentation (20%) Problem Definition Question Input, output, objective, constraints Importance Societal applications Long-standing open problems Hardness Challenges Large search space Response time constraints Uncertainty (e.g.. Model) Formal characterization (e.g., NP-complete) Approach First step in the right direction Description Key idea which can address the problem The challenges: special case and general case Examples / Justification Design decisions Pseudo code Execution trace Novelty Literature Survey Provide Examples as compared with the state of the art. Literature survey Detailed theorem, case study, exceptions General List other applications Detailed other applications.

11 Proposal (Due Oct. 12) Proposal should include a plan of work: Tasks
Schedule, resource, need People (e.g., skill and role)

12 SQL PostgreSQL

13 SQL is a very-high-level language.
Avoid a lot of data-manipulation details needed in procedural languages like C++ or Java. Database management system figures out “best” way to execute query (e.g., query optimization.)

14 Select-From-Where Statements
SELECT attributes FROM one or more tables WHERE condition about tuples of the tables ORDER BY attributes GROUP BY attributes

15 Example All our SQL queries will be based on the following database schema. Underline indicates key attributes. customer (customer_id, title, fname, lname, addressline, town, zipcode, phone) item (item_id, description, cost_price, sell_price) orderinfo( orderinfo_id, customer_id, date_placed, date_shipped, shipping) stock (item_id, quantity) orderline (orderinfo_id, item_id, quantity) barcode (barcode_ean, item_id)

16 ER Diagram orderinfo Customer item

17 Database Schemas

18 Define a new Schema CREATE SCHEMA schema_name; CREATE SCHEMA cop6726;
SET search_path TO myschema,public;

19 Example CREATE TABLE CREATE TABLE cop6726.customer (
customer_id serial, title char(4), fname varchar(32), lname varchar(32) not null, addressline varchar(64), town varchar(32), zipcode char(10) not null, phone varchar(16), CONSTRAINT customer_pk PRIMARY KEY (customer_id));

20 Example INSERT rows (or tuples)
INSERT INTO cop6726.customer (title, fname, lname, addressline, town, zipcode, phone) VALUES ('Miss','Jenny','Stones','27 Rowan Avenue','Hightown','NT2 1AQ',' '); INSERT INTO cop6726.item(description, cost_price, sell_price) VALUES ('Wood Puzzle', 15.23, 21.95);

21 DataSet

22 Retrieve all columns SELECT * FROM cop6726.customer;

23 Choosing Column(s) (Projection)
SELECT customer_id FROM cop6726.customer;

24 SQL SELECT customer_id, title FROM cop6726.customer;

25 Overriding Column Names
SELECT town, lname AS "Last Name" FROM cop6726.customer;

26 Order the Data SELECT town, lname FROM cop6726.customer ORDER BY town;

27 Order the Data SELECT town, lname FROM cop6726.customer ORDER BY town DESC, lname ASC;

28 Suppressing Duplication
SELECT town FROM cop6726.customer ORDER BY town; SELECT DISTINCT town FROM cop6726.customer;

29 Performing Calculation
SELECT description, cost_price FROM cop6726.item; SELECT description, cost_price * 10 FROM cop6726.item;

30 Choosing Row(s) (Selection)
SELECT title, fname, lname FROM cop6726.customer; SELECT title, fname, lname FROM cop6726.customer WHERE title='Mr';

31 Choosing Row(s) (Selection)
SELECT customer_id, town, lname FROM cop6726.customer WHERE customer_id BETWEEN 1 AND 5; WHERE customer_id >= 1 AND customer_id <=5;

32 Pattern Matching (Selection)
SELECT fname, lname FROM cop6726.customer WHERE fname LIKE '_n%'; WHERE fname LIKE '%n%';

33 Limiting the results SELECT customer_id, town FROM cop6726.customer LIMIT 3;

34 Equi-Join SELECT customer.customer_id, orderinfo.date_placed
FROM cop6726.customer, cop6726.orderinfo WHERE customer.customer_id = orderinfo.customer_id; orderinfo custsomer

35 Equi-Join

36 Alias SELECT c.customer_id, o.date_placed
FROM cop6726.customer c, cop6726.orderinfo o WHERE c.customer_id = o.customer_id;

37 Ordering Rows SELECT c.customer_id, o.date_placed
FROM cop6726.customer c, cop6726.orderinfo o WHERE c.customer_id = o.customer_id ORDER BY c.customer_id;

38 Equi-Join SELECT c.customer_id, o.date_placed
FROM cop6726.customer c, cop6726.orderinfo o WHERE c.customer_id = o.customer_id AND c.customer_id = 8;

39 Equi-Join SELECT c.customer_id, o.date_placed
FROM cop6726.customer c, cop6726.orderinfo o WHERE c.customer_id = 8; AND c.customer_id = o.customer_id

40 Cartesian Product (Cross Product)
SELECT c.customer_id, o.date_placed FROM cop6726.customer c, cop6726.orderinfo o WHERE c.customer_id = 8;

41 Cartesian Product (Cross Product)

42 Self Join SELECT o1.orderinfo_id, o1.customer_id, o2.orderinfo_id, o2.customer_id FROM cop6726.orderinfo o1, cop6726.orderinfo o2 WHERE o1.customer_id < o2.customer_id;

43 Self Join SELECT o1.orderinfo_id, o1.customer_id, o2.orderinfo_id, o2.customer_id FROM cop6726.orderinfo o1, cop6726.orderinfo o2 WHERE o1.customer_id < o2.customer_id;

44 Self Join SELECT o1.orderinfo_id, o1.customer_id, o2.orderinfo_id, o2.customer_id FROM cop6726.orderinfo o1, cop6726.orderinfo o2 WHERE o1.customer_id < o2.customer_id;

45 Self Join SELECT o1.orderinfo_id, o1.customer_id, o2.orderinfo_id, o2.customer_id FROM cop6726.orderinfo o1, cop6726.orderinfo o2 WHERE o1.customer_id < o2.customer_id;

46 GROUP BY SELECT o.customer_id FROM cop6726.orderinfo o
GROUP BY o.customer_id;

47 Aggregation Function SELECT o.customer_id, count (shipping)
FROM cop6726.orderinfo o GROUP BY o.customer_id; SELECT o.customer_id, avg (shipping) FROM cop6726.orderinfo o GROUP BY o.customer_id; SELECT o.customer_id, sum (shipping) FROM cop6726.orderinfo o GROUP BY o.customer_id; SELECT o.customer_id, max (shipping) FROM cop6726.orderinfo o GROUP BY o.customer_id; SELECT o.customer_id, min (shipping) FROM cop6726.orderinfo o GROUP BY o.customer_id;

48 Take Home Message Critical Reading ( 6 questions) Basic SQL


Download ppt "Introduction to Databases (2)"

Similar presentations


Ads by Google