Zhang Weiwu(familyname first):
>Hello. This is an another newbie question. And it is a bit off-topic. I
>post it here and I don't know where is the proper place to post it
Probably comp.databases or comp.lang.java.databases.
>I just wonder why now all the forum code writers love to put the article
>text and other information in to SQL or other types of database, instead of
>storing them directly into files, and let the OS's file system to optimize
>reading and writing, while storing articles seems have many benefit then
>using a database.
Why do you think that databases are less optimized for retrieving
information than file systems? Some database systems don't use file
systems at all but do raw I/O on partitions themselves.
>A forum messages is suitable for a file, especially when it contain HTML
>data, it is suitable for a HTML file.
Sure a message can be put in a file, but it can just as well be put
into a table column. Whether the content is plain text or HTML doesn't
make any difference (that I can see).
>a. with "forward" and "backward" meta data which is already defined as HTML
>standard ("forward" and "backward" article references also show clearer
>relationship to the search engines), the article thread information is
>clear, and can be somewhat forum-system independent.
The generated HTML from a database can contain <link> elements with
Prev, Next, Last, First etc. just as well.
>b. it makes export and import very much easier. Say a company wish to
>publish a disco of all the tech discussion happened last year, the
>administrator simple put all things in the forum folder to the disco and it
>is okay.
Why is that discussion available as HTML already? You can just as well
take the source data and put it in a database.
>c. It makes dynamic pages relatively static. A file based forum don't
>re-generate the article HTML page each time when someone asks for it, and
>dynamic pages like jsp are needed only when composing and editing message
>posts, saving lots of CPU time.
Generated pages can be cached.
>d. Another benefit of static pages are that it makes search engine easier to
>index. Many search engine don't store dynamic pages much, but they are well
>designed to index static pages.
Most databases come with built-in full text search. You specify which
columns to do full-text indexing on, and then all you have to do is
query the database. Adapting some search engine library / program is
harder.
>e. Many web servers are highly optimized for static page. Normally static
>pages are much faster.
The result of database queries can be cached as well.
>f. It could be easier to back up things. Using SQL your need to back up all
>stuff with capable knowledge.
A backup is relatively simple, databases usually come with some tool
that makes that quite easy.
Above I often stated that databases can be used "just as well". That
by itself isn't an advantage, obviously. Here are some reasons:
- Queries can be easily done with SQL. With files, you had to do a lot
of programming to accomplish the same thing. Basically you'd be
programming all that functionality that is already built into
databases.
- Many people know SQL and administrating databases. With a
file-system-based solution, nobody except you and your team had an
overview. Maintenance for others would be complex, and expensive for
those who own the place.
- SQL (or more general, RDBMSs) are old, proven technology. A
self-made solution using the file system is not. People have put
decades of research & development into existing databases. It's
unlikely that you can come up with something better in the short term.
- On many web servers some sort of database is installed for you to
use. Unless you control the server it is unlikely that you can run a
self-made program.
- Relational DBs are not natural for tree-like structures like
discussion forum message threads, but there is the nested set model
for that purpose (when insert is rare and select often):
<http://www.intelligententerprise.com/001020/celko.shtml>.
- There are ready-to-use solutions for web forums. Why start from
scratch (except maybe for the purpose of learning)?
Regards,
Marco
--
Please reply in the newsgroup, not by email!
Java programming tips:
http://jiu.sourceforge.net/javatips.html
Other Java pages:
http://www.geocities.com/marcoschmidt.geo/java.html