Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Design question - handling large text fields

Author  Topic 

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2005-07-18 : 19:57:05
Hi all,

We have a db under development here which has a requirement to hold large-ish text strings (probably up to 5000 characters, but there's no set limit AFAIK). Now I would have thought that a single text column would have sufficed, but the designers have done it differently. They have created a separate table containing an nvarchar(1000), which can have many records per parent record. So, the large string is split into 1k chunks and inserted into another table. Each of these child records has a sequence number to allow the string to be concatenated in the right order in the UI.
Is there any logical reason why they would have done it this way? I would have thought that a performance/storage hit at the db level would be preferable than having to code around this new design..

Cheers,

Tim

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-07-18 : 20:01:06
a lot of systems work this way. Working with large chunks of text is alwayws going to be somewhat inefficient anyway. This method takes more work from a a design perspective, but I cannot think of any reason why it wouldn't perform as well as having a single column varchar(5000). Also, working with TEXT datatypes is not very fun. Many (most actually) of the string functions do not work with TEXT datatypes. If you can use a varchar, use a varchar. This is probabaly why your devs did it this way.

Keep in mind that nvarchar means unicode. Unless you are storing unicode data there is no reason to use an nvarchar datatype.



-ec
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-07-18 : 21:03:24
They probably should use a Char(1000) or VarChar(1000).
I'd probably use a VarChar becuase the last "chunck" will waste a lot of space if it's a Char.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page
   

- Advertisement -