comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: GNATColl ORM problem (foreign key twins)
Date: Wed, 30 Oct 2013 12:43:51 +0000
Date: 2013-10-30T12:43:51+00:00	[thread overview]
Message-ID: <lysivjrks8.fsf@pushface.org> (raw)
In-Reply-To: 87zjprp1cz.fsf@adaheads.sparre-andersen.dk

Jacob Sparre Andersen <jacob@jacob-sparre.dk> writes:

> I want to model a collection of categories and subcategories in a
> database like this:
>
> | TABLE    | categories          | category        |  | Item categorisations |
> | name     | Text                | PK              |  |                      |
>
> | TABLE    | category_subsets    | category_subset |  | Item categorisations |
> | superset | FK categories(name) | NOT NULL        |  |                      |
> | subset   | FK categories(name) | NOT NULL        |  |                      |
>
> But this fails because GNATColl names the foreign key fields with the
> referenced field name instead of with the referencing field name.

I think that the problem is that the thing in brackets is not meant to
be the PK in the table that is being referenced, it's the name of the
reverse relationship. Look for 'revert_name' under [1] (I'm pretty sure
this should be 'reverse_name', BTW).

So yours would be

| TABLE    | category_subsets     | category_subset |  | Item categorisations |
| superset | FK categories(parents) | NOT NULL        |  |                    |
| subset   | FK categories(children) | NOT NULL        |  |                    |

and you get a function Parents that takes a Category and returns (a list
of?) Categories (a Category_Manager?).

[1] http://docs.adacore.com/gnatcoll-docs/sql.html#database-schema


  reply	other threads:[~2013-10-30 12:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-30  9:14 GNATColl ORM problem (foreign key twins) Jacob Sparre Andersen
2013-10-30 12:43 ` Simon Wright [this message]
2013-10-30 17:48   ` Jacob Sparre Andersen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox