Data-Storage Suggestions

J

Jonathan Wood

Hi,

I'd like to build a .NET Website that has any number of documents that
visitors can read. In addition to the documents, I may have one or two
downloads associated with each document. I'm trying to figure out the best
way of storing these files and documents (database vs. Web pages).

I asked this once before and got some comments about using both. And, in
fact, I've just been able to confirm that this is what sites like Code
Project do.

But, although I'm an experienced programmer, I'm relatively new to .NET and
Website database programming. So I must admit that I didn't understand most
of the suggestions I was given.

Does anyone know of an example or a site that documents, in some detail, how
one would approach this type of site?

Thanks for any suggestions.
 
S

sloan

For performance reasons, its usually best to keep a relative reference to a
file in the database, but keep the file on disk somewhere.

Lets take images of users for example.

You ~could store the image of each employee in the database.
Or...
you could store the relative url of each image in the database, and keep the
files statically in a folder on the web server.

For performance reasons, the 2nd one is more desirable. Because you hit the
db less (a filename is alot smaller than a big BLOB of data).
If the images don't change very often, then this is a good approach.

...

For hmtl pages, I'd consider saving the html in the database, but also
"publishing" them.
What I mean is that... if you have pages where users "create their own"
html.... then I'd keep that in the database.
I'd consider always getting the html from the database .... but then you're
incurring a db hit, just to render some html.
This is where I like the "hybrid" solution. You persist the html in the
database, but write it out to the webserver.
You get the perfformance of not hitting the database, because the pages are
written out as html. But you can allow users to edit, and then "publish"
updates.

If its pdf's, then the "keep the relative url" in the db is a good solution,
and just have copies of the pdf on the webserver.

You have to decide and architect based on certain decisons. that's why
there isn't one "right answer".
It depends how often the data inside the documents change, and if you need
to minimize the db hits....because you're web page needs to be scaleable.



But based on what you have in your description, I might do something like
this:

Document (table in the db)
DocUUID, DocName, DocRelativeURL


Download (table in db)
DownloadUUID, DocUUID, DownloadName, DownloadURL


You can create a strongly typed dataset. Fill it with the data from these 2
tables.


On your aspx page.. you'll bind a Repeater, or GridView (or 1.1 a datagrid)
to the Document(s) in the strongly typed dataset.
For each Document d in the Document table (each row basically), you'll
create a child Repeater or DataList to show the Downloads for each Document.

Here is an article. it is NOT exactly what you're looking for, but
http://www.code101.com/Code101/DisplayArticle.aspx?cid=68

http://www.code101.com/code101/Demos/demo68.aspx



will show how to loop on items, and then how to nest the children items.



You do not need the checkbox stuff. the more important things are the
DataList



the author there is NOT using a strongly typed dataset, fyi.



Unless you have a huge need... to write the actual content to the database,
I'd err on the side of relative URLS.





Ex data:

Document (table in the db)
DocUUID, DocName, DocRelativeURL
123,"Employee Phone List","/Files/employee.doc"
234,"Health Care Details","/Files/health_care.doc"


Download (table in db)
DownloadUUID, DocUUID, DownloadName, DownloadURL
1001,123,"How to Use Word",http://www.microsoft.com/howtouseword.rtf
1002,123,"Employee HandBook","/Files/emphandbook.pdf"
2001,234,"Met Life Rules",www.metlife.com/files/rules.txt
2002,234,"Met Life KB",http://www.metlife.com/kb.txt


how it comes out in aspx potentially
(HERE is a href )

Employee Phone List | Click HERE
--> Download "How to Use Word" HERE
-->Download "Employee Handbook" HERE
Health Care Details | Click HERE
--> Download "Met Life Rules" HERE
-->Download "Met Life KB" HERE


Take the example I give, and the demo from the other guy, and visualize what
the end might look at.
 
J

Jonathan Wood

Thanks Sloan,

Like I said, I'm pretty new to this stuff. I'll print out your response and
go over it in detail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,811
Latest member
SaulFernan

Latest Threads

Top