pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Filip Rembiałkowski <plk.zuber@gmail.com>
To: Andreas <maps.on@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to cascade information like the user roles ?
Date: Tue, 19 Jan 2010 15:27:39 +0100
Message-ID: <92869e661001190627i4d42e368nbb0e96bf5c54ca76@mail.gmail.com> (raw)
In-Reply-To: <4B54FDF3.4070601@gmx.net>
References: <4B54FDF3.4070601@gmx.net>

2010/1/19 Andreas <maps.on@gmx.net>

> Hi,
>
> I need something like the user-roles of PG to store options of my users.
> I guess i need a table with roles, options and one that stores the
> refernces from roles to options.
>
> roles (role_id, role_name)
> option (option_id, option_name)
> role_has_option (role_fk, option_fk)
>
> so far is easy. Now I can let role1 have option1 and option2 ...
>
> But I'd further like to let role2 inherit role1's options and also have
> option3.
> role_inherits_role (parent_role_fk, child_role_fk)
> 1, 2
>
> What SELECT would deliver all options for role2 inkluding the inherited
> ones?
> like
> role_id, option_id
> 2, 1
> 2, 2
> 2, 3
>


select role_fk as role_id, option_fk as option_id from role_has_option where
role_fk = 2
union
select inh.child_role_fk, opt.option_fk from role_has_option opt join
role_inherits_role inh on inh.parent_role_fk = opt.role_fk where
inh.child_role_fk = 2


?



> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



-- 
Filip Rembiałkowski
JID,mailto:filip.rembialkowski@gmail.com
http://filip.rembialkowski.net/

view thread (7+ messages)  latest in thread

Message-ID: <92869e661001190627i4d42e368nbb0e96bf5c54ca76@mail.gmail.com>
Permalink:  ../92869e661001190627i4d42e368nbb0e96bf5c54ca76@mail.gmail.com/
Also on:    postgresql.org/message-id/92869e661001190627i4d42e368nbb0e96bf5c54ca76@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: plk.zuber@gmail.com, maps.on@gmx.net
  Subject: Re: How to cascade information like the user roles ?
  In-Reply-To: <92869e661001190627i4d42e368nbb0e96bf5c54ca76@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox