How to use dynamic field type in mysql?
I want to design a little on-line store. The website should have every detail about products. Since I am beginner I stuck at designing good database design. There are many different products: Cellphone, Laptop, Stove, Bag, etc. Each of these products need different details. I am not going to design many different table for each, So one table (product) going to have all products. But How I manage details? I couldn't find good topic on Google so I started my own poor design. This is my draft design:opps can not post image
- Product stores product name.
- Product_category defines type of product, like: mobile or book. each product belongs to one product category
- Product_category_detail stores product attributes like color, wight, battery life etc. each product_category_details belongs to one product_category.
- Product_detail keeps values of detail like 3 hour for battery life, or 400g for wight. each of this belogns to one product category detail and product.
I can store all details in Var-char. Is it good? any suggestion! It's better to have type of detail. like varchar for color and int for wight. I am thinking on another field in product_catefory_datail named attr_type so I can change convert in php. Any idea? tnx
I had this similar issue while doing a project, and developed tables which solved my problem . Hope this helps you too.
pdfv_id,pdf_id,value,user_id //here pdf_id is fk of product_detail_fields
If you have multiple users, make use of
user_id, else ignore it.
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]