CodeBlanks Logo Icon CodeBlanks

Inventory design

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

query.sql
-- inventory table
CREATE TABLE inventory

Sample solution

query.sql
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

Question
CREATE ____ inventory (id INT PRIMARY KEY, qty INT);
Answer
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

All lessons in Beginner