0

Need help with linking tables - sql

Scenario and instruction /----------------------------------------------------------------------/ The fruit basket business is booming. And customers now want fruit baskets with more than one fruit in it. Baskets now also needs a name to differentiate them from each other. Create a new table called `fruit_basket_item` that contains: * 1 type of fruit, * a quantity of fruit * and the unit price per fruit. Create a new table called `multi_fruit_basket` it should have an `id` and a `name` column. The `fruit_basket_item` table should have a `multi_fruit_basket_id` column that should be a foreign key to the `id` column in the `multi_fruit_basket` table. /----------------------------------------------------------------------/ create table fruit_basket_item( fruit_type text not null, quantity int not null, unit_price float not null ); create table multi_fruit_basket( id serial primary key, fruit_name text not null, );

17th Nov 2021, 12:36 PM
Sisa
Sisa - avatar
2 odpowiedzi
+ 2
Here's how you can create foreign key field to refer other table's field https://www.w3schools.com/sql/sql_foreignkey.asp
17th Nov 2021, 1:42 PM
Ipang
- 2
Hi
17th Nov 2021, 1:07 PM
Siddiq
Siddiq - avatar