39 Replies
im trying to design ecommerce data base so i can use it
this is what i make !
https://drawsql.app/teams/nima-14/diagrams/shop
what thing i should chenge so i dont get any problem ?
is this good data base for manage product / category / and attributes ?
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
im trying to make digital shop ( phone , headphone , tv and ….
is my data base good for storing categoryis , colors , Ram , storage and …
?
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
i need to qurry them so i can show them
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 overkillso i should remove attribute category?
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
i dont know what i want 😅
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
i have all
already make frontend
as is, it looks like you have a solution to a non yet existing problem
then, you know what you need... no ?
im going to build dashboard and here i stuck cuse i cant fix my data base
do you have user stories? both for the front and back ?
its for portfolio
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
yes
user can select item in card and …
and owner
doesn't matter, or rather it does becausewriting user stories is a great skill to advertise
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
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
i make them in my brain
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
ye i think i should re make the data base and note what i want
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
i cheak many ecommerce website
and as you are making that for a portfolio it's important that you show this process, it's a really valuable skill
and i think frontend is ok
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
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 needin remaking and thinking agine
i re build it
can u say it is fix now ?
----------------
attribute : color
attribute_values : red ( color )
variant_attributes : product name ( color : red )
----------------
you have
product_variants
and variant_attributes
, which both have the product_id
foreign columni should give variant_attributes to -> product_variants
i think
what are you trying to store?
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
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