parent
a01ed53b6d
commit
15db656fc3
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
Sprint planning:
|
||||||
|
Determine tasks to be completed this week, with quick difficulty estimates. Tasks should be relatively small, specific, completable pieces of work. Plan how it's going to get done. Use the kanban in Gitea to populate it. Spring ends with next Monday's class meeting.
|
After Width: | Height: | Size: 7.9 KiB |
@ -0,0 +1,85 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Lab 1: Basic SQL Commands</title>
|
||||||
|
<link rel="stylesheet" href="../labGuide.css">
|
||||||
|
<style>
|
||||||
|
img {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="page">
|
||||||
|
<h1>Lab 1: Basic SQL Commands</h1>
|
||||||
|
<p>In this lab you get experience using basic SQL commands, using SQLite.</p>
|
||||||
|
|
||||||
|
<h2>Setting up</h2>
|
||||||
|
<p>
|
||||||
|
Open a text document and <a href="https://sql.js.org/examples/GUI/">this SQL interpreter</a> (clear out the default SQL supplied).
|
||||||
|
Throughout this exercise, test your SQL commands in the interpreter, but <strong>keep a copy of all of your working commands</strong> in your text document.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>Create tables</h2>
|
||||||
|
<p>
|
||||||
|
<img src="class diagram.png" width="350"><br>
|
||||||
|
Use the <code>CREATE TABLE</code> command to match the structure given in the diagram above. Here is the first one to get you started:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre><code>CREATE TABLE Customers(
|
||||||
|
CustomerID INTEGER PRIMARY KEY,
|
||||||
|
Name TEXT NOT NULL
|
||||||
|
);</code></pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Remember to name the primary key similarly to the table (e.g. <code>CustomerID</code> in the <code>Customers</code> table). The other two tables each have a foreign key (e.g. the <code>Orders</code> table will have a <code>CustomerID</code> column). Feel free to use the lecture notes as a guide. In SQLite, the <code>Date</code> can be stored as a <code>VARCHAR(10)</code> of the form <code>YYYY-MM-DD</code>. For price we will use the INTEGER type and store the number of cents, because floating points are prone to roundoff error hence should not be used for currency (other DBMS's support specific currency types).
|
||||||
|
</p>
|
||||||
|
<h2>Insert</h2>
|
||||||
|
<p>
|
||||||
|
Next, we will populate the tables using the INSERT command. For the customers table, use either
|
||||||
|
<code>INSERT INTO Customers (Name) VALUES('DrKow');</code> or <code>INSERT INTO Customers VALUES(NULL, 'DrKow');</code> for the first customer. Fill in two more customers: 'Plato' and 'Socrates'. You can view your progress by using <code>SELECT * FROM Customers;</code> or another similar SELECT command.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Fill in the Orders and LineItems tables to reflect the following orders.
|
||||||
|
<ul>
|
||||||
|
<li>On 2024-10-01, Plato ordered an NMU laptop for $165 and two power supplies for $22.95 each.</li>
|
||||||
|
<li>On 2024-10-10, DrKow ordered an optical mouse for $12.99 and an HDMI to USB-C adapter for $10.99.</li>
|
||||||
|
<li>On 2024-10-16, DrKow ordered an power supply for $22.95.</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
<h2>Select</h2>
|
||||||
|
<p>
|
||||||
|
Now time for some <code>SELECT</code> commands. Write the following 5 queries:
|
||||||
|
<ul>
|
||||||
|
<li>Show all data pertaining to all line items for Plato's order (you can use OrderID in the <code>WHERE</code> clause).</li>
|
||||||
|
<li>Get the total for Plato's order by changing the <code>*</code> in your previous command to <code>SUM(Price)</code> instead. This is known as an <em>aggregate function</em>.</li>
|
||||||
|
<li>Show the dates for all of DrKow's orders.</li>
|
||||||
|
<li>Show the customer name and date for all orders (you will need a JOIN).</li>
|
||||||
|
<li>Show the customer name and date for all orders, but still show the customers that never ordered anything (you will need a LEFT JOIN).</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
<h2>Update</h2>
|
||||||
|
<p>
|
||||||
|
Using an UPDATE command, change the price of the USB-C adapter to $8.99 in the 2nd order.
|
||||||
|
</p>
|
||||||
|
<h2>Delete</h2>
|
||||||
|
<p>
|
||||||
|
Using a DELETE command, delete the 2nd power supply from the first order.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>When you are done, show me your work to get credit for it.</p>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -0,0 +1,65 @@
|
|||||||
|
.tab {
|
||||||
|
padding-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #ffffb0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#page {
|
||||||
|
margin-left: 30px;
|
||||||
|
margin-right: 30px;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
background-color: #fffff0;
|
||||||
|
padding: 7px;
|
||||||
|
border-style: double;
|
||||||
|
border-color: #000000;
|
||||||
|
border-width: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.underline {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is so code samples look reasonable */
|
||||||
|
pre {
|
||||||
|
-moz-tab-size: 4;
|
||||||
|
-o-tab-size: 4;
|
||||||
|
tab-size: 4;
|
||||||
|
overflow-x: auto;
|
||||||
|
border-width: 1px;
|
||||||
|
border-color: black;
|
||||||
|
border-style: solid;
|
||||||
|
background-color: white;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote {
|
||||||
|
border-width: 1px;
|
||||||
|
border-color: black;
|
||||||
|
border-style: solid;
|
||||||
|
background-color: white;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.output {
|
||||||
|
border-width: 3px;
|
||||||
|
border-style: double;
|
||||||
|
border-color: white;
|
||||||
|
background-color: #000000;
|
||||||
|
color: #ffffff;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
Loading…
Reference in new issue