MC front end to PostgreSQL - lesson 1

Sadhunathan Nadesan sadhu at castandcrew.com
Mon Jan 27 19:36:01 EST 2003


Greetings all,

Building on the work of Pierre, I would like to share with you another
simple MC - web enabled - data base application.  This is another example
to show how it's done.  

Kindly pardon any over verbosity or belaboring the obious.  It's hard
to know who the audience might be, especially when emails are
archived, and it might be a newbie at some future date.

Perhaps if Pierre agrees I will post the actual stack on his ftp server,
similar to what he has put there.  I will take a slightly different
tact in describing things for the list, although the applications are
very similar.

Pierre, Swami and I sort of agreed to that .. he would show us, we
would write it up.  Ok, here goes.


1) Infastructure 
----------------

You need a web server running Apache or some other http server, and
a data base such as PostgreSQL, or similar.  I'm using RH Linux and
Postgres came installed so that was easy.  You also need the MC engine
installed on this server.  You don't necessarily need your own server;
for example, Sivakatirswami has MySQL installed on his "Hawaii on Line"
ISP and also MC installed, and he can add cgi scripts.  That's all
you need.  Obviously you need MC on the client side, and cgi enabled on
the server side.


2) Architecture 
----------------

This is a 3 part architecture.  The client side is an MC application,
a form with fields basically.  The fields obviously should correspond
to the fields in your data base on the back end side.  Ok, that is the
front end and the back end, the middle piece is a CGI program that
connects the two.  So you need 3 pieces.  I'm going to show you the
middle piece first.


3) Knowledge required 
---------------------

If you are on this list you probably already know a lot more about MC
than I do.  That's one reason my app is simple.  You would benefit from
some experience with simple CGI programming.  Basically, that just means
intercepting a 'post' command from a web page (html form), gathering
the data it sent, doing something with it, and usually, responding in
html format.  Knowing something about html is very helpful in CGI but not
much required for this app.   You would also benefit from experiences
with data bases, especially, working with SQL, although, again, not
too much knowledge is needed.  SQL is a very easy language to learn,
and you don't need to know very much for a simple app anyway.

We wrote the CGI in MC so you don't need Perl, C, shell script, etc.

However, one key to successful applications is data base design, so
it is suggested you would put in some effort getting that right before
building too much code for any real world application.


4) How it works
----------------

Very simple.  Your MC application sends a 'post' command < a stream of
data, in the form 'field_name=field_value', each such pair separated by
the "&" symbol > with the requisite fields off your form to the middle
layer cgi program.  The cgi program invokes the shell to make SQL calls
to your data base.  The results of the SQL operations are automatically
returned to your calling MC program as 'it'.  Nuthin to it, once
you've seen it done!



Ok, that's enough for lesson 1.  Stay tuned for lesson 2.  Oh, also,
disclaimer, this is a work in progress.

Sadhu



More information about the metacard mailing list