Forum Academy Marketplace Showcase Pricing Features

Does a product "have" a store or vice versa?

Hey guys.

I’m trying to build an Etsy style app and am wondering how the DB structure should work. Vendors can set up a store and list products on the store.

Buyers can search products by e.g. category, brand etc or go into the store and browse.

I’m don’t expect more than around 500 stores and fewer than 100 products/store.

I followed the Etsy clone instructions but discovered that it doesn’t include Store creation which has flummoxed me.

Can anyone point me in the right direction?

Cheers,
Raed

The Store is from a User;
→ So when creating a Store, you need to specify from which User is this store. So you need a field called “User” (Type = User) in your Store table.

The Product is from a Store;
→ So when creating a Product, you need to specify from which Store is this product. So you need a field called “Store” (Type = Store) in your Product table.

Doing this, you will keep things organized :+1:.

User > Store > Product

Sorry I forgot to mention something. Every product is unique to one store.

In this case, when displaying the products in the homepage and when searching products, would it be simpler/faster to have the product as the parent of the store and if it is, would can one create a store before creating products for the store?

Thanks

Doing what I said, every product will be unique to one store. So when your user click the product, you will already know the Store (Product → Store) and the user responsible for this store (Product → Store → User).

There are many different ways to structure your database. But I think this is the best in terms of performance, flexibility and organization. So, this beeing said, you need to have the store created before you be able to can create a product.