Practice
Build a pharmacy database from nothing with your own hands. Every step runs on a real server, and when you slip we explain why.
- 1Start
First day at work
\l · create database · \c
You have joined the “Shifo” pharmacy as a database intern. The books are still kept on paper — moving them into a database is your job. First, get to know the server.
0/4 steps - 2Start
The first shelf
create table · primary key · identity
In a pharmacy, medicines sit on shelves by category. In a database every “shelf” is a table. Your first table is the list of categories.
0/3 steps - 3Start
The first rows
insert into · select *
The shelf is ready but empty. Now we add rows. Remember: text values always go in single quotes.
0/3 steps - 4Start
Medicines and the foreign key
foreign key · references · date
The medicines have arrived. Each belongs to a category. Instead of repeating the category name every time, the medicine table stores just its number. That number is a foreign key.
0/4 steps - 5Start
Searching
where · like · order by · limit
The delivery truck has come — there are now eight medicines on the shelves. When a customer asks, you must find the right one fast. That is what `select` is for.
0/5 steps - 6Start
Fixing and cleaning
update · delete · where
A database is alive: prices change, expired medicines are removed. Careful — without `where` a command touches every row. In this mission, if you slip, the trainer puts the database back as it was.
0/4 steps - 7Start
Joining tables
join · count · group by
The medicine table holds the category number, but a customer wants a name, not a number. Linking two tables by their keys is called a `join`.
0/3 steps - 8Start
Final test: the first sale
M:N · join × 2 · sum
The last job is to record sales. One customer buys many medicines, and one medicine is bought by many customers. Such a many-to-many link needs a third table in between. No templates here — use what you have learned.
0/6 steps
Free play
A playground without checks: create your own databases and try any query you like. One button loads a ready-made pharmacy database with seven tables.