Understanding the OWS Database Tables
Now that you've reviewed the important database fundamentals, let's walk through the tables used in the Orange Whip Studios application (the database you'll be using throughout this book).
NOTE
Tables and table creation scripts for additional databases can be found on the book web site at http://www.forta.com/books/032122367 .The database is made up of 12 tables, all of which are related. These relationships are graphically shown in Figure 5.13.Figure 5.13. Many database applications allow relationships to be defined and viewed graphically.
Appendix G, "Sample Application Data Files," for a more thorough description of the tables used.
The Films Table
The Films table contains the movies list. The primary key for this table is the FilmID column.This table contains a single foreign key:
- The RatingID column is related to the primary key of the FilmsRatings table.
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
FilmID | Numeric | Unique ID for each movie; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
MovieTitle | Text | Movie title |
PitchText | Text | Movie pitch text; the tag line |
AmountBudgeted | Numeric, currency | Amount budgeted for movie (may not be equal to the actual cost plus expenses) |
RatingID | Numeric | ID of associated rating in the FilmRatings table |
Summary | Memo or long text | Full movie summary stored in a variable-length text field (to enable longer summaries) |
ImageName | Text | Filename of associated image (if there is one) |
DateInTheaters | Date | Expected movie release date |
The Expenses Table
The Expenses table contains the expenses associated with any movies listed in the Films table.
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
ExpenseID | Numeric | Unique ID for each expense; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
FilmID | Numeric | ID of associated movie |
ExpenseAmount | Numeric, or currency | Expense amount |
Description | Text | Expense description |
ExpenseDate | Date | Expense date |
- The FilmID column is related to the primary key of the Films table.
The Directors Table
The Directors table contains the list of directors. This table is related to the Films table via the FilmsDirectors table.
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
DirectorID | Numeric | Unique ID for each director; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
FirstName | Text | Director's first name |
LastName | Text | Director's last name |
The FilmsDirectors Table
The FilmsDirectors table is used to relate the Films and Directors tables (so as to associate directors with their movies).
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
FDRecID | Numeric | Unique ID for each row; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
FilmID | Numeric | ID of associated movie |
DirectorID | Numeric | ID of associated director |
Salary | Numeric, or currency | Director's salary |
- The FilmID column is related to the primary key of the Films table.
- The DirectorID column is related to the primary key of the Directors table.
The Actors Table
The Actors table contains the list of actors. This table is related to the Films table via theFilmsActors table.
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
ActorID | Numeric | Unique ID for each actor; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
NameFirst | Text | Actor's first name |
NameLast | Text | Actor's last name |
Age | Numeric | Actor's age |
NameFirstReal | Text | Actor's real first name |
NameLastReal | Text | Actor's real last name |
AgeReal | Numeric | Actor's real age (this one actually increases each year) |
IsEgomaniac | Bit or Yes/No | Flag specifying whether actor is an egomaniac |
IsTotalBabe | Bit or Yes/No | Flag specifying whether actor is a total babe |
Gender | Text | Actor's gender (M or F) |
The FilmsActors Table
The FilmsActors table is used to relate the Films and Actors tables (so as to associate actors with their movies).
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
FARecID | Numeric | Unique ID for each row; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
FilmID | Numeric | ID of associated movie |
ActorID | Numeric | ID of associated actor |
IsStarringRole | Bit or Yes/No | Flag specifying whether this is a starring role |
Salary | Numeric or currency | Actor's salary |
- The FilmID column is related to the primary key of the Films table.
- The ActorID column is related to the primary key of the Actors table.
The FilmsRatings Table
The FilmsRatings table contains a list of film ratings used in the Films table (which is related to this table).
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
RatingID | Numeric | Unique ID for each rating; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
Rating | Text | Rating description |
The UserRoles Table
The UserRoles table defines user security roles used by secures applications. This table isn't related to any of the other tables.
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
UserRoleID | Numeric | Unique ID of user roles; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
UserRoleName | Text | User role name (title) |
UserRoleFunction | Text | User role description |
The Contacts Table
The Contacts table contains a list of all contacts (including customers).
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
ContactID | Numeric | Unique ID for each contact; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
FirstName | Text | Contact first name |
LastName | Text | Contact last name |
Address | Text | Contact address |
City | Text | Contact city |
State | Text | Contact state (or province) |
Zip | Text | Contact ZIP code (or postal code) |
Country | Text | Contact country |
Text | Contact email address | |
Phone | Text | Contact phone number |
UserLogin | Text | Contact login name |
UserPassword | Text | Contact login password |
MailingList | Bit or Yes/No | Flag specifying whether this contact is on the mailing list |
UserRoleID | Numeric | ID of associated security level |
- The UserRoleID column is related to the primary key of the UserRoles table.
The Merchandise Table
The Merchandise table contains a list of merchandise for sale. Merchandise is associated with movies, so this table is related to the Films table.
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
MerchID | Numeric | Unique ID for each item of merchandise; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
FilmID | Numeric | ID of associated movie |
MerchName | Text | Item name |
MerchDescription | Text | Item description |
MerchPrice | Numeric or currency | Item price |
ImageNameSmall | Text | Filename of small image of item (if present) |
ImageNameLarge | Text | Filename of large image of item (if present) |
- The FilmID column is related to the primary key of the Films table.
The MerchandiseOrders Table
The MerchandiseOrders table contains the orders for movie merchandise. Orders are associated with contacts (the buyer), so this table is related to the Contacts table.
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
OrderID | Numeric | Unique ID of order (order number); can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
ContactID | Numeric | ID of associated contact |
OrderDate | Date | Order date |
ShipAddress | Text | Order ship to address |
ShipCity | Text | Order ship to city |
ShipState | Text | Order ship to state (or province) |
ShipZip | Text | Order ship to ZIP code (or postal code) |
ShipCountry | Text | Order ship to country |
ShipDate | Date | Order ship date (when shipped) |
- The ContactID column is related to the primary key of the Contacts table.
The MerchandiseOrdersItems Table
The MerchandiseOrdersItems table contains the individual items within an order. Order items are associated with an order and the merchandise being ordered, so this table is related to both theMerchandiseOrders and Merchandise tables.
COLUMN | DATA TYPE | DESCRIPTION AND SIZE |
---|---|---|
OrderItemID | Numeric | Unique ID of order items; can be populated manually when rows are inserted or automatically (if defined as an Auto Number field) |
OrderID | Numeric | ID of associated order |
ItemID | Numeric | ID of item ordered |
OrderQty | Numeric | Item quantity |
ItemPrice | Numeric or currency | Per-item price |
- The OrderID column is related to the primary key of the MerchandiseOrders table.
- The ItemID column is related to the primary key of the Merchandise table.
