3

I am developing Content Management System for my website. I am facing issues how to save large html content in database. Stored Procedures limits its parameters to 8000 characters, and not accept any content more than this length. so how could i store my content in database.

Or there is any other better way to do the job, where to save the html content. Also how the images (inside html) be stored, or its links, what would be the implementation scenario?

Lots' of CMS systems are running, how they have implemented this functionality.

Please suggest better ideas, how to deal with this requirement.

Tools I am using : C#.net SQL Server 2005 Asp.net 2.0

4 Answers 4

5

If you're using SQL Sever 2005, why not use the VARCHAR(MAX) datatype?

VARCHAR(MAX) and NVARCHAR(MAX) can hold the same amount of data that the old TEXT and NTEXT could hold (2 GB) but they are much more flexible than TEXT/NTEXT. They are stored in the same type of data pages used for other data types.

As far as what to do with images, my recommendation would be to store them in the filesystem and simply use normal img tags that point to them.

This is fairly typical for CMSes, to store article content in a table which would later be embedded in a template somewhere. Although document databases like MongoDB are increasing in popularity for this type of application.

Sign up to request clarification or add additional context in comments.

2 Comments

+1 - agreed. Specifying max gives you upto 2^31-1 bytes (2 GB), which should surely be enough.
+1. This is a "RTFM" type of answer as the OP states limitations out of his imagination, not out of the product to start with (SP#s limiting parameter length is not true as stated).
0

You may want to read up here regarding large-value data types - http://msdn.microsoft.com/en-us/library/ms178158(v=sql.90).aspx

You can use the large-value data types to store up to 2^31-1 bytes of data. Hope this helps.

Comments

0

Use blob fields in your database (e.g. BIGTEXT in MySQL). You can then stream your HTML content into the database field. Alternatively, if you want to take a documentum type approach, save the HTML content as a file and hold the location of the content in your database. The latter approach is good if you want to use hadoop and the like for searching huge amounts of content. If you are going for something simpler initially I would go with the blob approach as the searching of content in blobs has come on a long way in the last few years. However, be aware that clustered version of MySQL (for example) doesn't have great support for some things you might want such as xpath.

Comments

0

You should not save images, HTML or anything that won't be used in SQL WHERE statements. Instead, I would save those HTML code fragments and images on filesystem, something named like [PARENT_TABLE_NAME].[ROW_PRIMARY_KEY].html. This way you free up database time when querying since you probably won't use WHERE filters with those HTML fragments, and your HTML updates / deletes / inserts can't possibly be faster AND can be properly cached by OS.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.