School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011
-
Upload
quincy-joseph -
Category
Documents
-
view
31 -
download
3
description
Transcript of School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011
![Page 1: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/1.jpg)
School of SoftwareSUN YAT-SEN UNIVERSITYMar, 27, 2011
![Page 2: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/2.jpg)
The Procedure of Installing SQL Server 2005
• Microsoft SQL Server 2005 Express
• Microsoft SQL Server Management Studio Express
Introduction of TPC-H and Generate lineitem.tbl
Import Lineitem.tbl into SQL Server
Experiment about the Efficiency between Croup By
and Group By With Cube
![Page 3: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/3.jpg)
•Configuration demands
![Page 4: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/4.jpg)
•Install procedure for SQL server 2005 Express
![Page 5: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/5.jpg)
•Install procedure for SQL server 2005 Express
![Page 6: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/6.jpg)
•Install procedure for SQL server 2005 Express
![Page 7: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/7.jpg)
•Install procedure for SQL server 2005 Express
![Page 8: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/8.jpg)
•Install procedure for SQL server 2005 ExpressThis situation only for installing VS2005 already
![Page 9: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/9.jpg)
•Install procedure for SQL server 2005 Express
![Page 10: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/10.jpg)
•Install procedure for SQL server 2005 Express
![Page 11: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/11.jpg)
•Connect to SQL Server
![Page 12: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/12.jpg)
•Connect to SQL Server
![Page 13: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/13.jpg)
•The interface of SQL Server
![Page 14: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/14.jpg)
•The interface of SQL Server
![Page 15: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/15.jpg)
The TPC Benchmark™H (TPC-H) is a decision support benchmark.
The components of the TPC-H database are defined to consist of eight separate and individual tables.
![Page 16: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/16.jpg)
![Page 17: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/17.jpg)
•Get the tpch_2_14_0
• The DBGEN program can be downloaded at the following URL:http://www.tpc.org/tpch/spec/tpch_2_14_0.zip• The schema of LINEITEM can be found at page 12in the tpch2.14.0.doc, which can be downloaded at thefollowing URL:
http://www.tpc.org/tpch/spec/tpch2.14.0_cb.doc
![Page 18: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/18.jpg)
•Create lineitem.tbl (Linux)
![Page 19: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/19.jpg)
•Create a new query
![Page 20: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/20.jpg)
•Create database dbTPC
![Page 21: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/21.jpg)
•Use graphical interfaces
![Page 22: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/22.jpg)
•Use graphical interfaces
![Page 23: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/23.jpg)
•Create the table use SQLuse dbTPCcreate table lineitem( orderkey int,
partkey int,suppkey int,linenumber int,quantity int,extendedprice decimal,discount decimal,tax decimal,returnflag nchar(1),linestatus nchar(1),shipdate datetime,commitdate datetime,receiptdate datetime,shipinstruct nchar(25),shipmode nchar(10),comment varchar(44)
)
![Page 24: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/24.jpg)
•Create the table use interface
![Page 25: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/25.jpg)
•Step 1 Import file into SQL Server Using Bulk Insert.
BULK INSERT TablenameFROM 'D: \lineitem.tbl'WITH ( FIELDTERMINATOR = '|', ROWTERMINATOR = '|\r')
![Page 26: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/26.jpg)
•When GROUP BY and Aggregate Functions are used together, the practical meaning is significant.
• The Aggregate Functions generate a value for each group whenused together with GROUP BY, other than for the whole table.
![Page 27: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/27.jpg)
•Example: Display the how many lineitems are at each
returning status.
SQL:
SELECT returnflag, COUNT(*)
FROM lineitem
GROUP BY returnflag
![Page 28: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/28.jpg)
•Example: Display the quantity of lineitems which come from
the same order and at the same returning status.
order and they.
SQL:
SELECT returnflag, orderkey, SUM(quantity)
FROM lineitem
GROUP BY returnflag, orderkey
![Page 29: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/29.jpg)
The CUBE operator generates a result set that is a
multidimensional cube.
A multidimensional cube is an expansion of fact data,
The expansion is based on columns that the user wants to analyze
The cube is a result set that contains all the possible combinations
of the dimensions.
![Page 30: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/30.jpg)
SELECT Item, Color, SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Item, Color WITH CUBE
![Page 31: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/31.jpg)
SELECT Item, Color, SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Item, Color WITH CUBE
![Page 32: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/32.jpg)
•These four rows report the the original sum, in another wordsthis time we get four groups with their sum value.
SELECT Item, Color, SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Item,Color
![Page 33: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/33.jpg)
•These two rows report the subtotals for the Item dimension. both have null in the Color dimension to show that aggregate date came from rows having any value for the Color dimension.
SELECT Item, SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Item
![Page 34: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/34.jpg)
•These two rows report the subtotals for the Color dimension. both have null in the Item dimension to show that aggregate date came from rows having any value for the item dimension.
SELECT Color, SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Color
![Page 35: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/35.jpg)
•This row reports the grand total for the cube. All values of bothdimensions are summarized in the row.
SELECT SUM(Quantity) AS QtySum
FROM Inventory
•Then we can extend this situation to n dimensions. 2n different combinations of the dimensions should be considered.
![Page 36: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/36.jpg)
•Analysis the column orderkey, partkey, suppkey, linenumber of Table LineItem using WITH CUBE.
![Page 37: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/37.jpg)
•Using 16 GROUP BY clauses simulate the result set of GROUP BY WITH CUBE.
![Page 38: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/38.jpg)
GROUP BY millisecond
No grouping(1) 16
Group with 4 column(1) orderkey, partkey, suppkey, linenumber 31
Group with 3 column(4) orderkey, partkey, suppkey 31
orderkey, partkey,linenumber 16
orderkey, suppkey, linenumber 31
partkey, suppkey, linenumber 16
Group with 2 column(6) orderkey, partkey 16
orderkey, linenumber 15
orderkey, suppkey 16
suppkey, linenumber 15
partkey, suppkey 15
partkey, linenumber 15
Group with 1 column(4) orderkey 16
partkey 16
suppkey 31
linenumber 16
Total 302
GROUP BY WITH CUBE orderkey,partkey,suppkey,linenumber 140
![Page 39: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/39.jpg)
A. Use the DBGEN program of the TPC-H Benchmark to generate all the eight tables of the TPC-H schema, with the Scale Factor set to 1.
B. Create a database with eight tables including possible constrains(You can refer to tpch2.14.0.doc), and then import the generated data.
Submit all the nine queries and the time cost for importing data.
![Page 40: School of Software SUN YAT-SEN UNIVERSITY Mar, 27, 2011](https://reader035.fdocuments.net/reader035/viewer/2022081514/568131d9550346895d983fcc/html5/thumbnails/40.jpg)
THANK YOU!