Start from the entities and how they relate: customers, restaurants, menu items, orders, order lines, payments and delivery partners. Give each table a primary key, link them with foreign keys, and resolve many-to-many links with a junction table: order_items joins orders to menu items and records the quantity and the price paid. Then prove the design by writing a report on it, such as revenue by restaurant.
CREATE TABLE customers (customer_id INT PRIMARY KEY, name TEXT, city TEXT);
CREATE TABLE restaurants (restaurant_id INT PRIMARY KEY, name TEXT, city TEXT);
CREATE TABLE menu_items (item_id INT PRIMARY KEY, restaurant_id INT REFERENCES restaurants,
name TEXT, price NUMERIC(8,2));
CREATE TABLE orders (order_id INT PRIMARY KEY, customer_id INT REFERENCES customers,
restaurant_id INT REFERENCES restaurants, ordered_at TIMESTAMPTZ, status TEXT);
CREATE TABLE order_items (order_id INT REFERENCES orders, item_id INT REFERENCES menu_items,
quantity INT CHECK (quantity > 0), unit_price NUMERIC(8,2),
PRIMARY KEY (order_id, item_id));
Store the price paid on each order line, not just on the menu, or every menu price change rewrites past revenue.
PostgreSQL 18 docs: Constraints
Practise it with Prism