Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 408

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
A database commit occurs when you make a permanent change to a database. For example, when you write a new row
to a database, the write does not occur until the database commits the change.
Rollback is the process of undoing a change to a database. For example, if you write a new row to a table, you can
rollback the write up to the point where you commit the write. After the commit, you can no longer rollback the write.
Most databases support transactions where a transaction consists of one or more SQL statements. Within a
transaction, your SQL statements can read, modify, and write a database. You end a transaction by either committing
all your changes within the transaction or rolling back all of them.
Transactions can be useful when you have multiple writes to a database and want to make sure all writes occurred
without error before committing them. In this case, you wrap all writes within a single transaction and check for errors
after each write. If any write causes an error, rollback all of them. If all writes occur successfully, you commit the
transaction.
A bank might use a transaction to encapsulate a transfer from one account to another. For example, if you transfer
money from your savings account to your checking account, you do not want the bank to debit the balance of your
savings account unless it also credits your checking account. If the update to the checking account fails, the bank can
rollback the debit of the savings account as part of the transaction.
ColdFusion includes the
cftransaction
and commit. For more information, see the CFML Reference.
Database design guidelines
From this basic description, the following database design rules emerge:
• Each record should contain a unique identifier as the primary key such as an employee ID, a part number, or a
customer number. The primary key is typically the column used to maintain each record's unique identity among
the tables in a relational database. Databases allow you to use multiple columns for the primary key.
• When you define a column, you define a SQL data type for the column, such as allowing only numeric values to be
entered in the salary column.
• Assessing user needs and incorporating those needs in the database design is essential to a successful
implementation. A well-designed database accommodates the changing data needs within an organization.
The best way to familiarize yourself with the capabilities of your database product or database management system
(DBMS) is to review the product documentation.
Using SQL
The following information introduces SQL, describes basic SQL syntax, and contains examples of SQL statements. so
that you can begin to use ColdFusion. For complete SQL information, see the SQL reference that ships with your
database.
A query is a request to a database. The query can ask for information from the database, write new data to the database,
update existing information in the database, or delete records from the database.
Structured Query Language (SQL) is an ANSI/ISO standard programming language for writing database queries. All
databases supported by ColdFusion support SQL, and all ColdFusion tags that access a database let you pass SQL
statements to the tag.
tag that lets you implement database transactions for controlling rollback
Last updated 1/20/2012
403

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents