Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Best way to store data in table Expand / Collapse
Author
Message
Posted Thursday, February 21, 2013 4:15 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, February 21, 2013 5:45 AM
Points: 19, Visits: 8
hello,
I have aprox 70,000 words and want to store this data in DB, for this there are two ways as below:

1. add a single row that will have comma separated list of that 70,000 words. So the total records in the table will be 1

2. add all the 70,000 words as single single rows in table so total 70,000 rows in the table

what will be the best way to do this and why the solution is best. :)

Please explain... Thanks,
VinC
Post #1422496
Posted Thursday, February 21, 2013 4:44 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:10 AM
Points: 2,367, Visits: 4,409
It depends on your business requirement( What are you going to do with this 70,000 words? )

If you intend to handle each word differently by joining them individually to some other table, then its better to store them as 70,000 rows
But as I said, we can't decide without knowing the business requirement.



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1422499
Posted Thursday, February 21, 2013 4:48 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:11 AM
Points: 1,130, Visits: 1,278
Hi,

It depends on your requirement. If you to perform any operation on those words later like update etc. then its better you store those 70K words in 70K rows else you can store in a single rows of table with comma separated values.
Post #1422501
Posted Thursday, February 21, 2013 5:00 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, February 21, 2013 5:45 AM
Points: 19, Visits: 8
My requirement is like i have to search the word from this 70,000 words. so 1st i have to store that in the table then execute select statement with like operator. Also there will not be only 70,000 records it will be increased to may be 70,00,000 + too
Post #1422504
Posted Thursday, February 21, 2013 5:34 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 512, Visits: 2,244
You may want to consider Full-Text Search if your list is going to grow to 70 million+ words.

From MSDN:

A LIKE query against millions of rows of text data can take minutes to return; whereas a full-text query can take only seconds or less against the same data, depending on the number of rows that are returned.


-----------------------------------
http://www.SQL4n00bs.com
Post #1422508
Posted Thursday, February 21, 2013 5:39 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:10 AM
Points: 2,367, Visits: 4,409
vchauhan_me (2/21/2013)
My requirement is like i have to search the word from this 70,000 words. so 1st i have to store that in the table then execute select statement with like operator. Also there will not be only 70,000 records it will be increased to may be 70,00,000 + too


In that case its better if you store these rows in 70,000 different rows so that you can do a JOIN
You cannot do a JOIN with the word if you store all the words in a single comma separated row.



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1422509
Posted Thursday, February 21, 2013 5:47 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:11 AM
Points: 1,130, Visits: 1,278
Ok
then my suggestion is to store words in separate rows so that you can perform operation LIKE as you mentioned.
Post #1422512
Posted Thursday, February 21, 2013 5:48 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, February 21, 2013 5:45 AM
Points: 19, Visits: 8
Thanks for the reply from all of you, but i need the specific reason why separate rows (70,000 rows) are more preferable to store in DB in place of comma separated list, its like i need to search the keyword from the list but that is also done quite easily with comma separated record.

Is there any documentation for such thing then it will be good for me to clear this view.

but thanks for the reply
Post #1422513
Posted Thursday, February 21, 2013 5:53 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:10 AM
Points: 2,367, Visits: 4,409
vchauhan_me (2/21/2013)
Thanks for the reply from all of you, but i need the specific reason why separate rows (70,000 rows) are more preferable to store in DB in place of comma separated list, its like i need to search the keyword from the list but that is also done quite easily with comma separated record.

Is there any documentation for such thing then it will be good for me to clear this view.

but thanks for the reply


Can you replicate your problem with the help of a CREATE TABLE statement, some sample data( say 5 rows ) and the query you will be running on the table?
It will then be easier for us to give you better suggestions.



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1422517
Posted Thursday, February 21, 2013 5:55 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 8:18 AM
Points: 386, Visits: 1,424
INSERT INTO PseudoTable VALUES ('Tear,Bike,Monkey')

SELECT * FROM PseudoTable WHERE Item LIKE '%tea%'

1 row returned.



INSERT INTO PseudoTable VALUES ('Tear')
INSERT INTO PseudoTable VALUES ('Bike')
INSERT INTO PseudoTable VALUES ('Monkey')

SELECT * FROM PseudoTable WHERE Item = 'tea'

0 row returned.





The SQL Guy @ blogspot

About Me
Post #1422518
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse