0

Why people use database for web service?

What's wrong with create file and serving the files on the fly after request?

If I use CGI program to print out html file after user request, what kind of trouble would I face?

Can I only use http file server and CGI to create full-blown web site?

Jimmy Yang
  • 13
  • 1
  • 6

1 Answers1

0

There's nothing wrong with the method you suggest - many successful imageboards were built on that mechanism. However, a large site built on this method can become quite complicated.

People use databases for the functionality they offer:

Ad-hoc queries

For example, on an forum built on your method, you can't easily determine how many threads each board contains, or allow users to sort threads, without writing code for that purpose.

Easier to maintain

Schema changes are managed by the DBMS - no need to write code to iterate through the records in a file and update the layout of each.

Efficient

Fast data structures, indices and query planners can significantly outperform primitive file systems.

Data integrity

Database management systems support many constraint mechanisms to prevent and warn about attempts to modify the database in invalid ways.

For more, see database vs flat files or try a web search: advantages of a DBMS

Community
  • 1
  • 1
reaanb
  • 9,806
  • 2
  • 23
  • 37
  • I like your answer because it is not biased toward database. So basically database is the kind of package which provides the built-in functionality the file system lack of. However the effort put into transforming the multiple files into database might not be less than write out custom bash code to serve the content using CGI program. – Jimmy Yang Apr 06 '16 at 05:01