Making the skeleton
To illustrate
that it is not too difficult to get into using ceegeye with a database
using ajax this is a demo that introduces the basic
steps
needed to be productive. A very basic personnel database will
be used to demonstrate. Along with the database a
frontend (the html), backend (CGI programs) and the MySQL database.
Figure 1 is
a graphical
representation of the database and its table.
In the doc/util directory of ceegeye (e.g.
/usr/local/share/doc/ceegeye-<version>/html if installed to the standard location) is an html
file named 'mySQL-codegen.html' open
this file. This will provide a code base with which to base
the project. Go ahead and open this file in your browser (internet
explorer maybe a problem). Go ahead and read the blurb at the start of
the file.
Now you have the basics of the utility we will fill out the person
table. Fill in the fields for the person table as below. Here is
how we will map the Table person in database diagram figure 1 into the
table of the
database: figure 2
figure 2
Click the Make Code
button
to create the code. Now cut and paste each section of code
(delimited by horizontal rules on the page)
Each section of code has a comment at the top suggesting the names
for the files. Take these as the defaults, in this case personnel.h person.h person.cpp main.cpp personnel.sql Makefile
If you do not use these names the Makefile will have to be changed
(we will be changing the Makefile as we move along anyway as we
will be adding files and need further control over the linking of
the program). Put all these files in their own directory, change to
this directory at the command line and type make. Hopefully we got
no errors. You now have a working program. It is still of no use
though because we have not created the database.
Let's make a couple of changes to improve the database for
searching for personnel. Change to the Makefile to
make compilation simpler.
Open the personnel.sql file in a text editor and add INDEX userindex
(last, first)
after the Primary key reference in the evaluation table section.
This is not necessary but will help when searching for evaluations
in a large database, don't forget the comma after the PRIMARY key
line e.g. date
DATE NOT
NULL, PRIMARY
KEY
(id), INDEX
userindex
(last, first)
Now let's create the database. Open the Makefile in a text editor
and change the user in the createDB line to a user on your system
who has creation rights to MySQL, not a normal user a MySQL
user.
e.g.
createDB: mysql -u userWhoCanCreateDB -p < personnel.sql
to:
createDB: mysql -u root -p < personnel.sql
Now create the database by entering: make CreateDB
At the command line.
Now we can type make at the command line to compile everything,
nice and easy.
Now we have a skeleton it is time to make the application actually
do something.