Avatar of govindarajan78
govindarajan78
Flag for India asked on

comma separated values or separate table

Hi,

we have 2 tables; product and accessories; a product can have multiple accessories.

which approach is faster & better

a. store the accessories id as a comma separated value in the product table
b. create a separate table and store the relationship
    b. 1  table columns:  product_id,accessories_id   (composite primary key)
    b.2   table columns: id (primary key),product_id,accessories_id

Thanks

/govind
Web DevelopmentDatabasesMicrosoft SQL Server 2005

Avatar of undefined
Last Comment
govindarajan78

8/22/2022 - Mon
Ram4020

I would suggest b.2   table columns: id (primary key),product_id,accessories_id

This is more convenient and easy to store and fetch the records.
suryanshu

Ofcourse the option b
SO Basically you'll have 3 tables
products ---> prod_id (prim. key),name
accessories---> acces_id (prim. key),name
product_accessories  ---> id (prim. key),prod_id,acces_id
govindarajan78

ASKER
i am more worried about fetching the record; which is relatively faster? how?
Your help has saved me hundreds of hours of internet surfing.
fblack61
smash73

Hi govind,

Your question is good debate question.
For me, your questions answer depends upon a configuration you are using for client/ server.

For me option 2 is best practice and good approach.
Both will take approx same time depending on the amount of data.
Larger amount data is directly proportional to Option 2 as a solution.

Thanks
govindarajan78

ASKER
Hi smash73,
the data are growing to grow to thousands.
in the option b which one is better
ASKER CERTIFIED SOLUTION
Ram4020

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
govindarajan78

ASKER
can anyone explain how b.2 is better than b.1 at execution level
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
smash73

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
govindarajan78

ASKER
thanks a lot