Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Databases for Real

Fun with SQL

Creating Tables and Data

Issue: 1.4 (February/March 2003)
Author: Paul Lefebvre
Author Bio: Paul Lefebvre is a software architect in Portland, Maine.
Article Description: No description available.
Article Length (in bytes): 4,412
Starting Page Number: 27
RBD Number: 1413
Resource File(s):

Download Icon 1413.sit Updated: Friday, October 17, 2003 at 12:20 PM

Related Link(s): None
Known Limitations: None

Excerpt of article text...

Let's take the entities we created last time and turn them into tables. Once we do this we'll create these tables in a REALbasic database using SQL.

Mapping entities to tables is fairly straightforward. Typically, each entity becomes a table and each attribute becomes a column. You may have to do a few adjustments of table and column names to meet any restrictions of the specific database you are using. Also keep in mind that not every database has the exact same datatypes, so some changes may be necessary there as well.

Creating the SQL

Refer to the entities we created last time (see Figure 1). There's nothing fancy in the team entity (except that we'll use varchar instead of string), so its table create statement looks like this:

CREATE TABLE team (key integer not null, name varchar not null, coach varchar, primary key (key))

The key column is an artificial primary key. It is used in place of the team name so that we can more easily allow for changes to the team name after it has been used in other relationships.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com