Marketplace user's listings

Hello,

In my application there is a possibility to be a seller and a buyer. Now I want to create the page where user will be able to manage his products that he bought and sold. I want to use tab element with two different repeating groups.

User model has properties:
SoldProducts: List of products
BoughtProducts: List of products

I tried also create a table UserProducts with fields:
User: User
Product: Product
And tried to make a relation and simply take all records from this table where User == Current User and return all user’s products.

Now I want to ask you, if this structure is correct for my case and how I can present these fields in two different repeating groups?

Best Regards,
Mateusz

1 Like

Anyone?

Thanks!

Hey Mateusz,

I think you almost have it. The second option is a better way to lay out your database. I would suggest simplifying things by just having one table which represents all product listings. Each row would be a product that a seller created.

Table: UserProducts
Field 1: Product title
Field 2: product description
…all other standard fields you need for the product listing
Field X: status (live, withdrawn, sold)
Field Y: buyer (user) - only recorded once status changed to sold

So your two repeating groups would be:

  1. All products sold: Search for UserProducts where created by is current user and status is sold

  2. All products bought: Search for UserProducts where buyer is current user

I wouldn’t use the first structure as it’s less scalable (list fields don’t perform well as the list grows)

All the best
Rob

Just realised you have a separate Products table. What I’m suggesting is not having a separate UserProducts table as well but rather adding on the “status” and “buyer” fields onto your existing Products table.

That way you have everything you need in one table and don’t need to query different tables.

Yep because I just want to have relation between users and products. Also there could be more than one buyer of product. Imagine that you have 1000 quantity of product. So you mean to put “buyer” property in Products and add all 1k users to this property (1 user = 1 quantity assuming that this product will sold)? I see two ways to do that.

Table Users
Table Products → property buyer as list of users
Everytime need to add new user to the buyer list (there could be much more than 1000 buyers)

Table Users
Table Products
Table UserProducts → property User and Product.

I just implement the second option because I think that will be more effective than collecting Users in buyers list of Users, in Product table. What do you think?

Thanks!

Ah yes I was thinking these were one off sales rather than an e-commerce platform.

So I would have three tables:

  1. Users
  2. Products
  3. Sales

When a product is sold, you create a new Sale which records:

  • Product (which holds the Seller info too)
  • Buyer
  • Payment status, etc…

A user then sees their list of sold items by do a search for → Sales → constraints: Sale’s Product’s Creator is current user

Similar for bought items except search the buyer field

1 Like