Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Relationships.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00500362
Message ID:
00502042
Vues:
22
Keith,

Others have answered your issue about the clean up database option.

As for the One-To-Many versus a Many-To-One relationship, they are NOT exactly the same thing.

Let me explain; In the DBC (database) we define persistent relationships. These relationships exist for the exclusive purpose of enforcing referential integrity (in VFP they also provide for a default relaionship when using the visual designers). Persistent relationships are not meant to control the way data appears to a user.

For controling appearance we use either views, SQL Selects, or non-peristent relationships. What, you may ask, is a "non-persistent" relationship? It is one that is defined in code with a SET RELATION command or is defined in a Data Environment of a form or report. These relationships are called non-persistent because when you shut your system down they go away, to get them back you need to run the code that establishes them again (the relationships in the DBC do not go away when you shut the system down, thus they persist).

Persistent relationships ALWAYS originate from a primary or candidate index and terminate on another index. Non-persistent relationships begin from a field expression and terminate on an index, that is
SET RELATION TO <experssion> INTO <Alias>
expects the expression to be some field reference in the work area where the relationship originates and it expects that the target Alias has an index on a matching expression.

To see the difference between the 1-to-Many and the Many-to-1 assume the following tables;

Invoices

LineItems

where any invoice may have one or more line items. now you want to see an Invoice and its line items, this is a 1-to-many situation. You would relate Invoices into LineItems to get your result.

Now you are asked to report each product sold and the dates on which is was sold. Since the product ids are in LineItems and the invoice dates are in Invoice you would need to relate LineItems into Invoices to get your result, a many-to-1 relationship (the 1-to-many would not give what you need).

Why can't we get a many-to-1 in the Database, because we don't need them. Referential integrity doesn't care which way we relate the tables. Therefore we have only one direction in the dbc.

Does a persistent relationship from Invoices to LineItems prevent us from using a non-persistent relationship from LineItems into Invoices? No, not at all.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform