问题
Hello I have just started using Aerospike so I need some details what will be the good data model for my e-commerce platform, I am not able to design a data model for this in Aerospike which can work perfectly.
Here are some basic requirements for my e-commerce platform:
1.>User Set(For login & register an basic information of user)
2.>Product Set (For storing product info like name and image and options and color options etc)
3.>Order Set ( To track record of the user order )
The complex requirement for the special Set required for database is as follows:
1.For each product that a user will buy a Share Code will be generated which a user can share with his/her friends and family to get benefits for future.
2.The user who buys a product with somebody’s Share code, then the details that this user bought the “xyz” product must be transferred to the owner of the share code and also a Share code for this user will also be generate which he/she can share with his/her friend.
3.And also the user must be able to know how many persons shared his/her code an also the user’s who buys a product from the share code of the 1st level user’s Share Code.
- So I want to keep record of the users 2 level below the current user.
回答1:
Looks like you are trying to model a Multi-Level-Marketing order management system.
User and Product are straight forward. Records TTL = live for ever, never delete for all sets. user_info, product_info may be updated.
For simplicity, each product purchase is just one product_id. By PK I mean the primary key of the record.
User Set: {PK:user_id, user_info:{.....}}
Product Set: {PK:product_id, product_info:{.....}}
Order Set: {
PK: order_id,
order_details:{buyer:user_id,
item:product_id, qty:...,
share_code: "order_id:xyz",
parent_code:"parent_order_id:abc" },
level1_orders:[List of order_ids],
level2_orders:[List of order_ids]
}
The share_code is composite string comprising the order_id:some_code. For first set of orders (level 0 orders) parent_code may be zero.
Consider order_id = 213, share code: "213:abc", parent_code:"112:pqr"
If any user purchases using share code "213:abc", and this level 1 purchase order_id is 310, make entry in Order set for {PK:310, ... share_code:"310:cde", parent_code:"213:abc", ....} then update order_id=213 - to its level1_orders list, append 310 order_id.If order 213 has a parent_code, in this case it is "112:pqr" also update order_id 112 in its Level2 order lists by appending this order_id, 310 to it.
Now you have all the info you need for your model.
Note: This is a multi-record update model. Be mindful of potential inconsistencies if client fails midway or other bad things happen. There are advanced techniques to address that situation.
However, this may be a good starting point for you. Let me know if this was helpful. If it is different than what you wanted (your part 3 was not very clear to me), you may have to modify the model but the technique highlighted may be helpful.
来源:https://stackoverflow.com/questions/46474808/data-modeling-for-special-e-commerce-site-in-aerospike