Sw4   >   Sql   >   SQL

SQL

This section covers various topics about SQL (Sequential Query Language) as they relate to StudioWorks.

Parent/Child Tables

SQL is a relational database. This means that you can relate a record in one table to record(s) in another table.

Records are related through foreign keys. A foreign key is said to reference a column in another table. The referenced column is called the parent key and is normally the primary key of the referenced table.

Using the example of books and authors, a single author can write multiple books.

Author = parent table
Author_pkey = primary key

Book = child table
Book_fkey = foreign key

Referenced Table = Author
Referenced Column = Auhor_pkey
Parent key = Author_pkey

Base Schema

In StudioWorks when you create a query class that includes columns from more than one schema class you can specify one of the schema classes as the Base Schema, in the SQL class meta-data. The default is the schema class of the first column in the query class.

If the query class is used to insert, edit, or delete records - only the server table of the Base Schema will be affected when you issue a $doworkBatch.

Do QueryList.$doworkBatch() Return FlagOK

Warning

Only the columns of the Base Schema which are included in the query class will be updated by the $doworkBatch. Be sure to include the admin columns in any query class you use in an edit window.