We are creating a shop to sell different products from each of the gardens and need to create a database table of all the products available and a table which joins together the products and gardens
Create and seed a database for the shop_products
Database fields:
{ id: 1,
name: 'large veggie box',
description: 'a large box filled with fresh seasonal produce grown at your local garden',
price: 29,
image: 'www.linktowhereeverthisimageis.com',
}
Create and seed a database for garden_shop which joins the shop database and garden database together
Database fields:
{ id: 1,
garden_id: 3, //foreign key
shop_products_id: 2, //foreign key
stock: 15,
}
Create a db function and route '/api/v1/shop/:id' which sends back the products for a certain garden
Data contract (Shape of json to send):
[{ id: 1,
productId: 2
name: 'large veggie box',
description: 'a large box filled with fresh seasonal produce grown at your local garden',
price: 29,
image: 'www.linktowhereeverthisimageis.com',
stock: 15,
}]
Consider:
What tables you might need to join in order to get this information?
We are creating a shop to sell different products from each of the gardens and need to create a database table of all the products available and a table which joins together the products and gardens
Create and seed a database for the shop_products Database fields: { id: 1, name: 'large veggie box', description: 'a large box filled with fresh seasonal produce grown at your local garden', price: 29, image: 'www.linktowhereeverthisimageis.com', } Create and seed a database for garden_shop which joins the shop database and garden database together Database fields: { id: 1, garden_id: 3, //foreign key shop_products_id: 2, //foreign key stock: 15, } Create a db function and route '/api/v1/shop/:id' which sends back the products for a certain garden Data contract (Shape of json to send): [{ id: 1, productId: 2 name: 'large veggie box', description: 'a large box filled with fresh seasonal produce grown at your local garden', price: 29, image: 'www.linktowhereeverthisimageis.com', stock: 15, }] Consider: What tables you might need to join in order to get this information?