[Haskell-cafe] Compulsory relation 1 to many from entity A to entity A

Justin Bailey jgbailey at gmail.com
Mon Feb 11 12:46:32 EST 2008

On Feb 9, 2008 2:12 AM, news at lyra.net <news at lyra.net> wrote:
> I'd like to build a database model with winHugs that allows
> a "recursive relation". For example a single instance of
> entity "components" is related with at least another row of
> the entity "components" (1 to many relationship). How can I
> do that?

A very simple approach is to use a recursive data type:

  data Relation = Relate Component [Component]

If components store their relations, then

  data Component = Component { related :: Maybe [Component] }

There are much more complicated but type-safe approaches too. What are
you looking to do?


More information about the Haskell-Cafe mailing list