Above all else, building any substantial
project requires organization. You can be the best coder in the
world, but if the project is not well-organized, it will take longer
to put together than it should. The longer you spend planning, the
greater chance you will have of bringing a project in on time and
under budget. With that in mind, we'll prepare for
the coding first by laying out all the requirements, setting up a
specification, creating a code skeleton framework, and finally
getting down to some coding.
The example application uses ColdFusion MX as the server model. Many
of the concepts translate directly to other server models, and
we've tried to leave the implementation as generic
as possible to facilitate porting. Porting the example to other
server models such as ASP.NET, Java, or PHP is left as an exercise
for the reader.
The code shown in the examples uses
<cfquery> tags for all databases queries.
We've kept the query in the page purely to keep the
implementation generic; these queries will work in SQL Server, as
well as MS Access or MySQL, which do not support stored procedures.
If your database supports stored procedures, you will want to move
the queries into stored procedures.
When inserting records into a database, you'll often
need to retrieve the primary key of the newly inserted record. There
are various methods to do this in different Relational Database
Management Systems (RDBMS), but the example application uses a
generic method that will work in different databases. When a new user
is inserted, you can use the username to retrieve the
UserID; usernames are unique in the database. When
inserting a script, we'll also insert a unique
identifier that will aid in retrieving the
ScriptID for a particular script.