• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
advice how to store to database

#1
Hey all, i am a starting webdevloper, and this is the first time i am going to work with codeigniter.

First of all sorry for my english, its not that good but i hope you can understand me Smile

but now i need some advice(not codeigniter related) currently i am working on webshop/service system.

what i want to archieve, i have parent category, that contains sub category's.
every sub category could be products or different services.

for example
parent1
-parent1sub1
-parent1sub2
-parent1sub3
-parent1sub4

ect.

Where sub1 is a sub category that containts downloadable products
sub2 contains non downloadable products
sub3 contains a type of service
and sub4 also contains a type of service.


now i need some advice what you guys should do with storing this all in the database

shall i create a own table for service/digital produtcs/normal products?.

and if i create a own table for each service/product type how would i store the information for orders?

normally you would have a orderDetails table where you store all products for that order, how would i store products/service from multiple table?
just create a own colum for service/product in the table orderDetails?


I hope you have some advice for me Smile

jaap
Reply

#2
You have a category table which has a parent category ID in it (thus you've now setup your category to subcategory requirement), then each category has a type (like service, digital product, normal product) in the table.

One category table manages it all.

When you need digital products, search just by the type of product; likewise for normal products, search by type.
When you need all subcategories under a category, search the parent_category_ID

that should do what you want.
Reply

#3
Hello, thanks for you reaction

currently i have splitted it in 2 table's category and subcategory,each subcategory is linked to the serviceType table to see what type product/service it is and what layout its linked to this product/service.

this isnt really the problem where i need some advicee, maybe i didnt explain it well.

normal when you have a single table called products, where you store product id, subcategroy and all product info.

but now i have multiple kind of products(digital/normal) and services. what is the best option for this.

products and services have common things. like a name/desc/base price/categorie/. but also different things like for products i need keep track on the stock, while for service now.

i can store products/service in the same table productAndService and then additional fields in a own table and linked to each related product or service.

or i can create different table's for products and service. but when i do this. wouldnt be this more complex for orders.

when i have a everything stored in a single table productAndservice i can simply get the product/service from one table.
like order_details
id--productAndServiceId-amount-price
1 -- 15 - 2 - 15,00
2 -- 8 - 1 - 20,00

how i would do this when i store products/service in a own table? just add a extra colum to order details?
Reply

#4
Maybe this will help.

Pivot Tables in MySQL
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.