You are on page 1of 3

INF 202 / CSS 206 – DATABASE MANAGEMENT SYSTEMS 1

Lab Assignment 1.

Environment Setup
In this lab section you need to prepare the environment to work with SQL queries, i.e. to install necessary
software. You need to install SQLite database and a GUI for SQLite database – VS Code. Note you need to
install the version of these software depending on your Operating System (Linux, MacOS or Windows).

1. Download and install SQLite (http://www.sqlite.org/). In order to test whether it works you may use the
terminal. See the instructions in the manual (https://www.sqlite.org/cli.html).
2. Download and install VS Code (https://code.visualstudio.com/Download). It is a general purpose in-
tegrated development environment (IDE) that supports multiple programming languages. In order to have
special support for SQLite, you have to install the SQLite extension directly inside VS Code
(https://github.com/AlexCovizzi/vscode-sqlite).
3. Create a new folder using VS Code – click New Window. This will open a new window where on the left panel
you can see Explorer.

4. Create a folder for this lab – click Open Folder and create a folder (name it as Lab1) on your computer.

Schema Creation
In order to load the data, first you must create the schema for the relations. In this class we will work on a type
of Transaction Processing Performance Council (TPC) DBMS benchmark – called TPCH
(http://www.tpc.org/tpch/).

Figure 1: TPCH benchmark.

• nation (
– n nationkey decimal(3,0) not null,
– n name char(25) not null,
– n regionkey decimal(2,0) not null,
– n comment varchar(152)
)
• region (
– r regionkey decimal(2,0) not null,
– r name char(25) not null,
– r comment varchar(152)
)
• part (
– p partkey decimal(10,0) not null,
– p name varchar(55) not null,
– p mfgr char(25) not null,
– p brand char(10) not null,
– p type varchar(25) not null,
– p size decimal(2,0) not null,
– p container char(10) not null,
– p retailprice decimal(6,2) not null,
– p comment varchar(23) not null
)
• supplier (
– s suppkey decimal(8,0) not null,
– s name char(25) not null,
– s address varchar(40) not null,
– s nationkey decimal(3,0) not null,
– s phone char(15) not null,
– s acctbal decimal(7,2) not null,
– s comment varchar(101) not null
)
• partsupp (
– ps partkey decimal(10,0) not null,
– ps suppkey decimal(8,0) not null,
– ps availqty decimal(5,0) not null,
– ps supplycost decimal(6,2) not null,
– ps comment varchar(199) not null
)
• customer (
– c custkey decimal(9,0) not null,
– c name varchar(25) not null,
– c address varchar(40) not null,
– c nationkey decimal(3,0) not null,
– c phone char(15) not null,
– c acctbal decimal(7,2) not null,
– c mktsegment char(10) not null,
– c comment varchar(117) not null
)
• orders (
– o orderkey decimal(12,0) not null,
– o custkey decimal(9,0) not null,
– o orderstatus char(1) not null,
– o totalprice decimal(8,2) not null,
– o orderdate date not null,
– o orderpriority char(15) not null,
– o clerk char(15) not null,
– o shippriority decimal(1,0) not null,
– o comment varchar(79) not null
)
• lineitem (
– l orderkey decimal(12,0) not null,
– l partkey decimal(10,0) not null,
– l suppkey decimal(8,0) not null,
– l linenumber decimal(1,0) not null,
– l quantity decimal(2,0) not null,
– l extendedprice decimal(8,2) not null,
– l discount decimal(3,2) not null,
– l tax decimal(3,2) not null,
– l returnflag char(1) not null,
– l linestatus char(1) not null,
– l shipdate date not null,
– l commitdate date not null,
– l receiptdate date not null,
– l shipinstruct char(25) not null,
– l shipmode char(10) not null,
– l comment varchar(44) not null
)
1. Look through the SQLite features. Tutorial about SQLite is here:
https://www.tutorialspoint.com/sqlite/sqlite_create_database.htm
2. Create a database named TPCH and name it tpch.sqlite – you may use the terminal inside VSCode.
3. Open the newly created database in VSCode – press Ctrl+Shift+P to list the commands. Then, type Open
database in the search box to find the database file.
4. Create the following tables with their corresponding schemas:

Submission Instructions.
1. Create a separate file and put your DDL queries into the file. Make sure each DDL query is separated by a
semicolon (;) otherwise the file will not run in the script that will be used to evaluate your work. Name the
file as Lab1-DDL.sql.
2. Take a screenshot of your created tables created in your database tpch.sqlite (name the screenshot as Lab1-
tables.png). Make sure the screenshot is clearly visible.
3. Create a folder and put the aforementioned files into the folder (name it as Lab1-StudentID). Zip(archive)
the folder Lab1-123456789.zip. Do not include any other files into the folder since it may fail the tests that
are used to evaluate your work. Upload the archived folder to moodle.sdu.edu.kz under under Lab1.

You might also like