Inventory design
- SQL course
- Beginner
- Lesson 107/115
- 5 min
Set up product and category tables and write skeleton queries.
Inventory table
In this project you will build an inventory system. First step is to create the inventory table.
CREATE TABLE inventory (
id INT PRIMARY KEY,
name VARCHAR(100),
qty INT,
location VARCHAR(50)
);Table with id, name, qty and location columns.
The table inventory is created.
Inventory table — details
The inventory table holds product name, quantity and location. PRIMARY KEY makes id unique.
Practice Inventory table
Create inventory with id INT PRIMARY KEY, name VARCHAR(100), qty INT, location VARCHAR(50).
Starter code
-- inventory table
CREATE TABLE inventorySample solution
CREATE TABLE inventory (
id INT PRIMARY KEY,
name VARCHAR(100),
qty INT,
location VARCHAR(50)
)Expected output
Tablo oluşturuldu
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does the inventory table hold?
- Only the date
- Product, quantity and location Correct answer
- Only the name
- Only the price
Explanation: Inventory holds product, quantity and location.
2 Create table
CREATE ____ inventory (id INT PRIMARY KEY, qty INT);
CREATE TABLE inventory (id INT PRIMARY KEY, qty INT);
Explanation: The inventory table is created with CREATE TABLE.
3 Inventory design: match the terms
| Term | Meaning |
|---|---|
CREATE TABLE |
create table |
INSERT |
insert |
SELECT |
read |
UPDATE |
update |