relation two levels deep

Hi

I have a question concerning the design of a form and the envolved relations: Imagine a table persons, a table orders and a table parts. A person may have n orders, each order consists of m parts. On a persons form I want to list all parts (in a form on a tabless tab panel) for a person. What tables should my forms use? How should this be designed?

If I use the db relations (persons-orders and orders-parts) I either see all orders for a person or all parts for an order. But how can I list all parts for a person? If I add a form to a tab panel I cannot go two levels deep with the relation, can I?

What I did is: I added a new relation between persons and parts. But we are not sure if this is the best way to do it. Somehow we thought, the relations defined in the db should be enogh. Is there an other way to list the entries of a table two relations away?

Thanks for help and reagrds
Birgit

birgit:
I have a question concerning the design of a form and the envolved relations: Imagine a table persons, a table orders and a table parts. A person may have n orders, each order consists of m parts. On a persons form I want to list all parts (in a form on a tabless tab panel) for a person. What tables should my forms use? How should this be designed?

I would use the parts form (in an un-related tab) and load it using a SQL query. No Servoy relationships used.
Just trigger this method on the onShow and onRecordSelect events.

birgit:
If I use the db relations (persons-orders and orders-parts) I either see all orders for a person or all parts for an order. But how can I list all parts for a person? If I add a form to a tab panel I cannot go two levels deep with the relation, can I?

No, you can only show data in calculations and labels x levels deep. You can’t link a form 2 or more levels deep.

Hope this helps.

Hi

Yes, this helps. Thank you for the clarification.

Since I have attribute person_id in table persons and person_id in table parts, a relation is easy to define. Would you still go with an SQL query and do it “by hand”? What advantage would this be?

Thank you and regards
Birgit Rieder

If you have that person_id in parts, I’d use a relation right away. I guess Robert didn’t expect that column in the parts table (why is it there?).

Ehh… yeah indeed. Just use a direct relation then.
But why the question about relations 2 levels deep then ? :)

I came up with this question (as explained before) since the relation I used now, was none of our data model. In the model do only exist relations between persons and orderes and between orders and parts. Until now I was only defining relations in Servoy, which exist in our data model. And somehow we thought this is the way to go. This should be enough. Thats why we were not sure if we missed something important here.

Actually, we are often uncertain if we go the best way or a good way in Servoy. Or how it could be done easier. I’m glad to let this confirm in the forum then.

So, thanks for the answers and regards
Birgit