Contents:
Introduction
News blog
What is Servoy?
Getting Started
Comparison Servoy/VFP
Performance
How-To's
Code Reference
VFP2Servoy Toolkit
Contact / feedback
|
How to create a relation
We know about relations in VFP and that they are used to tie two tables together using
key-fields (usally a primary key and a foreign key). In Servoy this is also the case. However
there are a few differences as well.
In VFP we have referential integrity and cascading deletes but the relation only applies to our
native Visual FoxPro tables. In Servoy the relation is more of a logical object
telling the application how tables are related in stead of forming the actual relation.
With this information Servoy takes care of everything like applying key-values to the
specified fields in the database when adding records or filtering the data of a related table to
match only the corresponding child-records.
In Servoy relations can also be used to join tables from completely different databases.
Lets take a look at a typical one-to-many data-entry scenario where parent and child records are
combined in one form. In this example we will use the customers/orders tables from the
example_data database.
- In your solution locate the Relations node and right-click it
- From the popup-menu select Create relation
- Press the Source select button
- Expand the example_data database and select the Customers table
- Press Ok button
- Press the Destination select button
- Expand the example_data database and select the Orders table
- Press Ok button
- Press Ctrl+S to save the relation
That's all! Now we are ready to use the relation in situations where data-entry is done in
related tables. To see this relation put to practice go to the
Add a portal (vfp: grid) to a form walkthrough.
Note that if you did not fill in the relationname yourself that Servoy generated one based on
the tables you chose (customers_to_orders).
|
External resources:
vfp plugin
ServoyWorld 2012 pics
Official Servoy website
Ken Levy on Servoy
Servoy info
Servoy Forum
Servoy Documentation
|