13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with local SQL databases in AIR<br />

Using a primary key, you can set up relationships betwe<strong>en</strong> multiple tables. For example, suppose the “fri<strong>en</strong>ds” table<br />

has a column “fri<strong>en</strong>d id” that contains a unique number for each row (each fri<strong>en</strong>d). The related “phone numbers” table<br />

can be structured with two columns: one with the “fri<strong>en</strong>d id” of the fri<strong>en</strong>d to whom the phone number belongs, and<br />

one with the actual phone number. That way, no matter how many phone numbers a single fri<strong>en</strong>d has, they can all be<br />

stored in the “phone numbers” table and can be linked to the related fri<strong>en</strong>d using the “fri<strong>en</strong>d id” primary key. Wh<strong>en</strong> a<br />

primary key from one table is used in a related table to specify the connection betwe<strong>en</strong> the records, the value in the<br />

related table is known as a foreign key. Unlike many databases, the AIR local database <strong>en</strong>gine does not allow you to<br />

create foreign key constraints, which are constraints that automatically check that an inserted or updated foreign key<br />

value has a corresponding row in the primary key table. Nevertheless, foreign key relationships are an important part<br />

of the structure of a relational database, and foreign keys should be used wh<strong>en</strong> creating relationships betwe<strong>en</strong> tables in<br />

your database.<br />

About SQL<br />

Adobe AIR 1.0 and later<br />

Structured Query Language (SQL) is used with relational databases to manipulate and retrieve data. SQL is a descriptive<br />

language rather than a procedural language. Instead of giving the computer instructions on how it should retrieve data,<br />

a SQL statem<strong>en</strong>t describes the set of data you want. The database <strong>en</strong>gine determines how to retrieve that data.<br />

The SQL language has be<strong>en</strong> standardized by the American National Standards Institute (ANSI). The Adobe AIR local<br />

SQL database supports most of the SQL-92 standard.<br />

For specific descriptions of the SQL language supported in Adobe AIR, see “SQL support in local databases” on<br />

page 1093.<br />

About SQL database classes<br />

Adobe AIR 1.0 and later<br />

To work with local SQL databases in ActionScript 3.0, you use instances of these classes in the flash.data package:<br />

Class Description<br />

flash.data.SQLConnection Provides the means to create and op<strong>en</strong> databases (database files), as well as methods for performing<br />

database-level operations and for controlling database transactions.<br />

flash.data.SQLStatem<strong>en</strong>t Repres<strong>en</strong>ts a single SQL statem<strong>en</strong>t (a single query or command) that is executed on a database, including<br />

defining the statem<strong>en</strong>t text and setting parameter values.<br />

flash.data.SQLResult Provides a way to get information about or results from executing a statem<strong>en</strong>t, such as the result rows from<br />

a SELECT statem<strong>en</strong>t, the number of rows affected by an UPDATE or DELETE statem<strong>en</strong>t, and so forth.<br />

To obtain schema information describing the structure of a database, you use these classes in the flash.data package:<br />

Class Description<br />

flash.data.SQLSchemaResult Serves as a container for database schema results g<strong>en</strong>erated by calling the<br />

SQLConnection.loadSchema() method.<br />

flash.data.SQLTableSchema Provides information describing a single table in a database.<br />

Last updated 6/6/2012<br />

715

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!