I’m sure you are quite familiar with HTML pages or web-pages, as they are
popularly called. These are pages stored on the web server, which you can
download into your browser by typing in the website address or by clicking on a
hyperlink that points to that page. This seems rather easy. So we’re not
looking at simple web pages or websites. In this article, we would be looking at
something far more complex–namely, dynamic web pages and websites!
The Need for Databases
Let me start off with a story.
Whichever city or town you live in, I’m sure you have a favorite sabzi-wala,
who comes around to your house every day with his cart piled up with greenish
potatoes, stale onions, sorry-looking peas, and beans that may have been fresh a
week ago. However, that is not the point. The point is that he sells you
something every day. And for example’s sake let’s call him Haribhai. Thanks
to the online medium, your good old honest sabzi-wala need not visit you any
more. Why? Because
he’s launched his own website, www.sabziwala.com.
And, his young nephew, who is under training to become a proud sabziwala in his
own right some day, delivers whatever you order on the Internet.
Haribhai has engaged a leading American multinational (headquartered in
Boston, Massachusetts) to create his e-commerce software, which is naturally
full of HTML pages, each page containing vegetable listings, package sizes,
prices for each, time to deliver, and so on and so forth.
Suddenly one day there is a rumor that the transporters of the area may go on
strike. And Haribhai realizes with that he can now charge twice as much for the
same old stale vegetables. But when he goes to the MNC, to ask if they could
modify the rates in his website, he is in for a big shock. "Sorry, sir, but
we’ll have to change the HTML pages. And that means you need our programmers
all over again. And that will mean an additional sum of about $10,000. But since
you are a valued customer and a major account for us, we’ll cut it down to
just $8,000," came the reply.
Haribhai is shattered. How can he possibly make up this money even if he
charges three times the normal rate. And then he gets another terrible thought–tomorrow,
when the rumor is squashed by the appropriate government official, he would have
to bring the prices down again. So he would again need to go back to the
multinational - $8,000 once again. And indeed every time he changed the price of
his vegetables; the gainer would only be the software company!
Apart from feeling sorry for Haribhai, can we really offer a solution?
Indeed, there has to be a solution, because the data that you put out on your
HTML page needs to be changed at regular intervals. In fact, there are many
software companies that have moved from HTML websites to dynamic websites, which
use relational databases.
Dynamic and Static Sites
A database in the basic sense can be defined as a collection of data–obviously
organized in some manner. And you can query this database to get whatever data
you want. Databases are an essential component of any website today, and in fact
of any computer-based application, whether on the Internet or otherwise. So let’s
take a look at Haribhai’s vegetable database. Assuming he needs to store three
pieces of information–name of the vegetable, size of packing, and price. The
database would then be in the form of a table (See Table 1).
The |
||
Name of vegetable |
Size of pack (kg) |
Price of pack (Rs) |
Onion | 0.5 | 20 |
Onion | 1 | 38 |
Potato | 1 | 15 |
Potato | 2 | 28 |
Tomato | 0.5 | 15 |
Tomato | 1 | 28 |
Tomato | 2 | 54 |
Notice that this table defines a "relationship" between name of
vegetable, size of pack, and price of pack. Consequently it doesn’t take much
imagination to see why such a database is called a relational database. In fact
the table itself is often called a relation!
Now let’s see how we can query such a database. If we wanted to get the
price of a half kilo pack of onions, we would give a command to the database
which would look something like this: "Get the price of pack for the row
where name of vegetable is ‘onion’, and size of pack is ‘0.5 Kilos’
And naturally, the result will be another table–this time a smaller one.
And the result of the query is price of pack–Rs 20. Notice that the result of
the query doesn’t need to give the first two entries (name of vegetable and
size of pack). Because you know that anyway–after all you were the one who
asked the question. It’s like an exam where the student doesn’t have to
write down the entire question along with the answer–just the answer will do,
as long as he writes down the question number.
This type of querying is usually done in a standardized language called SQL,
which stands for structured query language. Obviously it is more formal than the
simplified stuff I have been showing you, but the essence is the same. Now,
Haribhai’s problem can be finally solved
Because now, whenever Haribhai needs to change prices, he doesn’t need to
change the entire HTML page. He doesn’t need a programmer. Most of all, he
certainly doesn’t need the Boston-based multinational. All he needs is someone
who understands simple English, who can enter this data into the database every
time it changes. In fact, his 12-year old niece who goes to an English Medium
school could do the job.
Another advantage of having an improved website is that it gives you one more
set of technical jargon that you can brag about, namely dynamic sites and static
sites. A static website is one, which consists of HTML pages that are permanent
and cannot be easilty modified or updated. Any changes in such a site require an
entire re—programming of the HTML coding. Therefore such sites are useful in
cased where infomation does not have to be changed very often.
On the other hand, dynamic sites are those where the web page is created
dynamically–as in our example–through a database, instead of being
permanently coded in HTML. As discussed, these sites are useful when some of the
HTML pages need the flexible option of editing and upgrading a part or the
entire data. In other words, these kind of websites can be called that
database-driven sites as they are more maintainable than plain HTML websites,
which are simply based on static HTML pages.
So, where does all this information that is constantly being updated get
saved and stored? This data is resting on a separate server called the data
server. The data server is generally connected to the web server through a LAN
or local area network link (See Fig. 1).
Fig 1: The data |
At end of the day, Haribhai got a solution to his problem, and without
burning a hole in his pocket! Needless to say, his website is a roaring sucess.
DHRUV NATH is a Professor at MDI,
Gurgaon.