News Feed Comments

Releasable Revolution

Creating release quality applications with Revolution

  • Home
  • Tutorials & Manuals
  • Articles
  • Revolution Tools
    • Libraries
      • SQL Yoga
      • GLX Application Framework
      • libDatabase
    • Externals
      • EQT
    • Plugins
      • Script Format Helper
      • BBEdit Language Module
  • About
Tutorials & Manuals » SQL Yoga Examples » Brief Introduction to Using Table, Relationship and Scope Objects

Subscribe to our feed

SQL Yoga: A Flexible Database Library for Revolution.

SQL Yoga page

Buy now

Last Updated

Sep 24, 2009

Download Lesson PDF

Download Manual PDF

Other Resources

  • How-tos

  • Lessons
  • GLX Application Framework

  • GLX Application Framework 1.1
  • Converting An Existing Application To Use The Framework
  • SQL Yoga

  • SQL Yoga
  • SQL Yoga Examples
  • SQL Yoga To-Do Application
  • SQL Yoga IDE Plugin
  • Plugins, Externals and Libraries

  • Plugins

Comments

0 comments for this lesson

  • Prev: The Regions Tab
  • Next: The Departments Tab

Brief Introduction to Using Table, Relationship and Scope Objects

The examples you've read about thus far haven't required any particular configuration on your part. All the code you have seen is possible by just connecting to a database with SQL Yoga.

Now you know how to use the basic features of SQL Query and SQL Record objects. Let's look at three more objects that can make you even more productive, but which require a little configuration on the part of the developer. The objects are:

1) Table Objects
2) Relationship Objects
3) Scope Objects

Before we look at examples of how to use these objects we need to discuss where you configure them.

The "tables behavior" Property

Media_1253089688211

To configure a SQL Yoga Database object (a Database object is where all other SQL Yoga objects are stored) you need to create a button and assign it to the table objects behavior property of the object (1). In the sample application that button is named Table Objects Behavior (2). It is an invisible button on the same card as all of the other controls.

The dbobject.createTables Message

Media_1253850809455

There are a number of features that the tables behavior script can add to SQL Yoga. For now we are just going to look at the dbobject.createTables message. dbobject.createTables is where you should create any and all objects that you want to access through the SQL Yoga API. You can assume that no objects exist when this message is called so you should create everything from scratch.

SQL Yoga will call this message in two circumstances:

1) You call the command dbobject_createObject and pass in the table objects behavior button as the 2nd parameter.

2) You call tableobjects_reload which essentially erases existing objects and calls dbobject.createTables.

If you decide you need to add objects to your SQL Yoga database object then simply update the script and call tableobjects_reload.

Creating Objects

Media_1253850905076

The first thing you want to do in dbobject.createTables is create Table objects for any tables you will be working with (1). Table objects are necessary in order to create Relationship and Scope objects (2).

Creating Relationship Objects

Media_1253552775239

Relationship objects tell SQL Yoga about how database tables are related to each other. This enables SQL Yoga to transform results it gets from the database into multi-dimensional arrays and link records in two tables together among other things. Creating a relationship is relatively straight forward.

1) Provide a name for the relationship.

2) Define the type of relationship. The type can be one-to-one, one-to-many or many-to-many.

3) Configure the left and right tables, along with the columns in each table that are used to "connect" the tables together. It may be helpful to think think of the left table as the parent and the right table as the child in the relationship.

4) Alternatively specify the table and column that SQL Yoga should use to sort records.

Creating Scope Objects

Media_1253090028269

A Scope object is attached to a Table object. It allows you to define a very narrow search condition that can be used with a SQL Query object. Scopes are useful when you have a number of search conditions that you want to dynamically apply to a search. You can easily add in the scopes you need to the SQL Query object based on user input and SQL Yoga will generate a complete search condition for you based on all added Scopes.

When creating a Scope object you:

1) Specify the table the scope is associated with.

2) Give the scope a unique name.

3) Specify the search conditions. Usually you want to keep the condition very narrow in focus. In this example there is one scope pertaining to the department a town is a part of. Another is just for searching on a town name.

  • Prev: The Regions Tab
  • Next: The Departments Tab

Comments (0)

Add your comment

E-Mail me when someone replies to this comment
  • ScreenSteps Desktop

    ScreenSteps Desktop helps you help other people.

    Teachers can teach, Bloggers can demonstrate, Tech Support can communicate, Developers can document, Trainers can instruct.

    All in a matter of minutes.

    Learn More

  • ScreenSteps Support Suite

    We're Revolutionizing the Way Organizations Help Their Customers

    Join Us

    Create, distribute and aggregate “Just In Time” tutorials that help your customers and ease your support load.

    Learn More

  • revSelect Add-Ons

    Supercharge your Revolution development with RevSelect products.

© 2009 Releasable Revolution