Article Preview
Buy Now
COLUMN
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): 5,276
Starting Page Number: 27
Article Number: 1413
Resource File(s):
1413.zip Updated: 2013-03-10 15:00:53
Related Link(s): 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.