Relation naming for ORDA in v17? Best Practices anyone?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Relation naming for ORDA in v17? Best Practices anyone?

4D Tech mailing list
Hey all of you ORDA pioneers and converts!


Have any of you come up with a convention for naming relations for use with
ORDA? What have you found that works? or doesn't?


----------------------------------------------------------------------------
------------------------

Edgar Hammond                                    
[hidden email]

Quest Information Systems

----------------------------------------------------------------------------
------------------------
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Relation naming for ORDA in v17? Best Practices anyone?

4D Tech mailing list
Yes, since years i use the following:

Given two tables:

[Invoice]
[InvoiceItems]

The id from the invoice is named as:

[InvoiceItems]_Invoice__

(one leading underscore and double underscore as postfix)

For ORDA i name the relation:

[InvoiceItems]_Invoice__MO

(MO means Many to One) which is an entity and

[Invoice]_InvoiceItems__OM

(One to Many) which is an entitySelection
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
[hidden email]
Tel: +49/(0)40/52 10 59-23




> Am 08.02.2019 um 19:50 schrieb Ed Hammond via 4D_Tech <[hidden email]>:
>
> Hey all of you ORDA pioneers and converts!
>
>
> Have any of you come up with a convention for naming relations for use with
> ORDA? What have you found that works? or doesn't?
>
>
> ----------------------------------------------------------------------------
> ------------------------
>
> Edgar Hammond                                    
> [hidden email]
>
> Quest Information Systems
>
> ----------------------------------------------------------------------------
> ------------------------
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************


--
heubach media
Osterfeldstr. 12-14 | Haus 1 | Eingang Nord
22529 Hamburg
tel: 040 / 52 10 59 - 10 | fax: -99
mail: [hidden email]
home: www.heubach-media.de
Geschäftsführer|CEO: Matthias Heubach

Mieten Sie Ihre Computer, iPads & Drucker für Ihre Events bei:
http://www.milo-rental.com

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
 
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Relation naming for ORDA in v17? Best Practices anyone?

4D Tech mailing list
Given two tables:

[Invoice]
[InvoiceItems]


I went much simpler…

The many to one from InvoiceItems to Invoice I simply name invoice
The one to many from Invoice to Invoice Items I simply named invoiceItems

Then the dot notation comes out to be

Invoice.invoiceItems
InvoiceItems.invoice




Neil






**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Relation naming for ORDA in v17? Best Practices anyone?

4D Tech mailing list
> I went much simpler…

This is quite the same, but the problem with this approach is, that i cannot parse relations generically.
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
[hidden email]
Tel: +49/(0)40/52 10 59-23




> Am 08.02.2019 um 20:15 schrieb Neil Dennis <[hidden email]>:
>
> Given two tables:
>
> [Invoice]
> [InvoiceItems]
>
>
> I went much simpler…
>
> The many to one from InvoiceItems to Invoice I simply name invoice
> The one to many from Invoice to Invoice Items I simply named invoiceItems
>
> Then the dot notation comes out to be
>
> Invoice.invoiceItems
> InvoiceItems.invoice
>
>
>
>
> Neil
>
>
>
>
>
>


--
heubach media
Osterfeldstr. 12-14 | Haus 1 | Eingang Nord
22529 Hamburg
tel: 040 / 52 10 59 - 10 | fax: -99
mail: [hidden email]
home: www.heubach-media.de
Geschäftsführer|CEO: Matthias Heubach

Mieten Sie Ihre Computer, iPads & Drucker für Ihre Events bei:
http://www.milo-rental.com

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
 
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Relation naming for ORDA in v17? Best Practices anyone?

4D Tech mailing list
In reply to this post by 4D Tech mailing list

> Le 8 févr. 2019 à 19:50, Ed Hammond via 4D_Tech <[hidden email]> a écrit :
>
> Have any of you come up with a convention for naming relations for use with
> ORDA? What have you found that works? or doesn't?

Hi Ed,
the relation name is the direction in which we go from one field to another. Thus I stick to my table and fields naming to identify in the relation name:
- the destination table
- the direction (many to one ≠ one to many)
The "from" is unnecessary (redundant) because ORDA starts with it:
  ds.dataclass.{property}

For example:
  [company]PK ............ primary key
  [employee]FK_company ... foreign key
  company_p .............. relation to one   {from ds.employee}
  employee_f ............. relation to many  {from ds.company}

ORDA will be like this:
  ds.employee.company_p … (many to one, to Primary…)
  ds.company.employee_f … (one to many, to Foreign…)

BTW, in french, "p" stands for "père" (father) an "f" for "fils" (sons), it suits me. Maybe an english reader would prefer O, M, for one, many, use a prefix instead. Some like plural/singular I've seen, like "company" and "allEmployees". Too much grammar for me  ;-)

As two fields in the same table can't have the same name, two properties in the same entity must have different names. In case of multiple relation, I still follow my foreign keys naming, I add to the names what makes them different. For example this table:
  [Human]
   PK
   FK_humanFather
   FK_humanMother
Relations:
  from PK to FK_humanFather: humanFather_f
  from PK to FK_humanMother: humanMother_f
  from FK_humanFather to PK: human_p, father_p, etc.
  from FK_humanMother to PK: human_p, mother_p, etc.

--
Arnaud de Montard



**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Relation naming for ORDA in v17? Best Practices anyone?

4D Tech mailing list
In reply to this post by 4D Tech mailing list

> Le 8 févr. 2019 à 20:18, Christian Sakowski via 4D_Tech <[hidden email]> a écrit :
>
>> I went much simpler…
>
> This is quite the same, but the problem with this approach is, that i cannot parse relations generically.

I do agree, a name that allows to identify the function is great:
  find regex("^FK_";property;1) -> foreign key
  find regex("_p$";property;1) -> many to one relation
And these names are not supposed to change every day…  

--
Arnaud de Montard





**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Relation naming for ORDA in v17? Best Practices anyone?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
I always use singular table names and the relationship names are singular or plural based on their type. For example, I have a structure that imports 4D code and builds a database of each method path and the related methods it directly calls:

[Method_Call]ID

[Method_Call]Caller_Method_ID -> [Method]ID
M to 1: Caller
1 to M: Method_Callers

[Method_Call]Callee_Method_ID -> [Method]ID
M to 1: Callee
1 to M: Method_Callees

John DeSoi, Ph.D.



> On Feb 8, 2019, at 12:50 PM, Ed Hammond via 4D_Tech <[hidden email]> wrote:
>
> Hey all of you ORDA pioneers and converts!
>
>
> Have any of you come up with a convention for naming relations for use with
> ORDA? What have you found that works? or doesn't?

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Relation naming for ORDA in v17? Best Practices anyone?

4D Tech mailing list

> Le 9 févr. 2019 à 15:31, John DeSoi via 4D_Tech <[hidden email]> a écrit :
>
> I always use singular table names and the relationship names are singular or plural based on their type. [...]

Hi,
using grammatical rules makes reading code closer to human langage. But I prefer to have the target table name in the relation name, as Christian said it allows generic treatments:
- in french many names have the same singular and plural (mouse -> souris/souris, contest -> concours/concours)
- in english it seems easier but there are many plurals that will not allow to get the table easily (tooth/teeth, story/stories, fish/fishes)

--
Arnaud de Montard





**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************