Ecommerce data base

hello
39 Replies
NIMA
NIMAOP6d ago
im trying to design ecommerce data base so i can use it
NIMA
NIMAOP6d ago
DrawSQL
Shop | DrawSQL
Database schema diagram for Shop.
NIMA
NIMAOP6d ago
what thing i should chenge so i dont get any problem ? is this good data base for manage product / category / and attributes ?
Rägnar O'ock
Rägnar O'ock6d ago
without knowing what are your functionnal requirements (i.e. what your thing is supposed to do) it's hard to say anything. I don't see any blatant error, but they might crop up depending on what you want to do
NIMA
NIMAOP6d ago
im trying to make digital shop ( phone , headphone , tv and …. is my data base good for storing categoryis , colors , Ram , storage and … ?
Rägnar O'ock
Rägnar O'ock6d ago
like the attribute stuff, respect normal forms. but you might not need it if you never query them and it might actually cost you performance if you make wide queries. when you design a database you have to think about what you want to query it for, not just what you will store into it like if you never ever query attributes it might be more efficient to just store a flat JSON string in a text or JSON field
NIMA
NIMAOP6d ago
i need to qurry them so i can show them
Rägnar O'ock
Rägnar O'ock6d ago
you don't need to query them to display them, you need a query that has their field in the select but that's not a query of that specific field a better word that query might be "filter" tho. like do you ever want to say "give me all products with this attribute" ? if no, then having 3 tables and having to maintain relations among them might be overkill
NIMA
NIMAOP6d ago
so i should remove attribute category?
Rägnar O'ock
Rägnar O'ock6d ago
as for the data, you might want to add support for product and brand images I don't know, you didn't explain your requirements so I'm just pointing out things that might become issues later on, but you need to either be more precise with what you want to do or see for yourself if what I pointed (or what others might point) might apply to what you are making
NIMA
NIMAOP6d ago
i dont know what i want 😅
Rägnar O'ock
Rägnar O'ock6d ago
that's might be your issue right there you might be trying to take the problem by the wrong end try to make your UI and your User Stories for what you want to do first, then look for solutions to those
NIMA
NIMAOP6d ago
i have all already make frontend
Rägnar O'ock
Rägnar O'ock6d ago
as is, it looks like you have a solution to a non yet existing problem then, you know what you need... no ?
NIMA
NIMAOP6d ago
im going to build dashboard and here i stuck cuse i cant fix my data base
Rägnar O'ock
Rägnar O'ock6d ago
do you have user stories? both for the front and back ?
NIMA
NIMAOP6d ago
its for portfolio
Rägnar O'ock
Rägnar O'ock6d ago
like "as a client I can add an item to my cart" or "as an seller I can update a product's description", that kinda things
NIMA
NIMAOP6d ago
yes user can select item in card and … and owner
Rägnar O'ock
Rägnar O'ock6d ago
doesn't matter, or rather it does becausewriting user stories is a great skill to advertise
NIMA
NIMAOP6d ago
can make product category and auttrube like if owner post a iphone 15 he can choose colors and how many storeg also how many in stock and i make this with the thing
Rägnar O'ock
Rägnar O'ock6d ago
alright, so you don't have them written down xD you need to go over what you have, and write senarios of how a user might use your thing. write them down, one sentence per senario then once you have that, look at your DB and check that you can implement every senario you listed
NIMA
NIMAOP6d ago
i make them in my brain
Rägnar O'ock
Rägnar O'ock6d ago
if you can't find how to implement a senario it means your DB structure isn't right and you need to adapt it to fit, then check again all the scenarios until all of them can work with your DB structure write them on a napckin if you want, it doesn't really matter
NIMA
NIMAOP6d ago
ye i think i should re make the data base and note what i want
Rägnar O'ock
Rägnar O'ock6d ago
what matters is that you can see them all, and you can refer to them it's your requirements use a napkin, a .txt file in notepad++, a markdown file in obsidian, a powerpoint presentation, an excel file or whatever you want but write them down and make sure you cover all the use cases you want to have then check that your implementation means those requirements and not just the DB, check your front-end too, you might realise that you missed some stuff from from you wanted to do
NIMA
NIMAOP6d ago
i cheak many ecommerce website
Rägnar O'ock
Rägnar O'ock6d ago
and as you are making that for a portfolio it's important that you show this process, it's a really valuable skill
NIMA
NIMAOP6d ago
and i think frontend is ok
Rägnar O'ock
Rägnar O'ock6d ago
you think, you aren't sure writing stuff down, and validating it makes you sure of it just pretend you are a safety inspector with their pen and woodboard taking note that stuff works as specified or whatever
ἔρως
ἔρως6d ago
it's very obvious that the design of the database was made without any planing you want data in, you want it to respect database rules, you shoe-horned the kiki shape into the square hole the design has categories, brands, stock keeping thrown into product variants, attributes (???) and what-not for example, the brands have a name and id, but don't have a logo - the most recognizable part of a brand the product variants have a "stock" column, but don't have a name column how will users select the variants if they don't know what they are? the product_attributes table has an attribute id that's related to ... attribute_values and has an unnecessary id column and doesn't have the value of the attribute which is in the attributes_values which has an attribute_value column (????????) and att_category_id related to ... [sic] attribute_categroy this whole products attributes needs to be re-done it's a mess you really need to plan what you want and need
NIMA
NIMAOP6d ago
in remaking and thinking agine
NIMA
NIMAOP6d ago
NIMA
NIMAOP6d ago
i re build it can u say it is fix now ? ---------------- attribute : color attribute_values : red ( color ) variant_attributes : product name ( color : red ) ----------------
ἔρως
ἔρως6d ago
you have product_variants and variant_attributes, which both have the product_id foreign column
NIMA
NIMAOP5d ago
i should give variant_attributes to -> product_variants i think
ἔρως
ἔρως5d ago
what are you trying to store?
NIMA
NIMAOP5d ago
category -> and brand -> then a product ! product can be phone like iphone 15 i phone 15 can have diffrent color and storeg and each phone with diffrent color can have diffrent photos i think data base good but not sure ? what u think
Rägnar O'ock
Rägnar O'ock5d ago
you should really write down what you want to do, it will help you figure out what you need to do. having it just in your head will get you nowhere plus it'll make it easier for you to ask for help on a precise issue instead of "does it feel right" without much context

Did you find this page helpful?