Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id C94883405C7 for ; Wed, 22 Feb 2012 07:25:42 -0400 (AST) Received: from hub.ringways.co.uk ([77.86.27.30] helo=mail.ringways.co.uk) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S0AKL-0005BM-6I for pgsql-sql@postgresql.org; Wed, 22 Feb 2012 11:25:42 +0000 Received: from localhost ([127.0.0.1] helo=mail.ringways.co.uk) by mail.ringways.co.uk with esmtp (Exim 4.69) (envelope-from ) id 1S0AK2-0005zT-2m for pgsql-sql@postgresql.org; Wed, 22 Feb 2012 11:25:23 +0000 Received: from eddie.ringways.co.uk ([10.1.1.115] helo=eddie.ringways.co.uk) by mail.ringways.co.uk with ESMTP id qBPC10Mi08547; Wed, 22 Feb 2012 11:25:12 +0000 From: Gary Stainburn Organization: Ringways Garages Ltd To: pgsql-sql@postgresql.org Subject: Re: Another constant in foreign key problem. Date: Wed, 22 Feb 2012 11:25:15 +0000 User-Agent: KMail/1.9.10 References: <201202221035.11963.gary.stainburn@ringways.co.uk> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201202221125.15486.gary.stainburn@ringways.co.uk> X-SpamTest-Envelope-From: gary.stainburn@ringways.co.uk X-SpamTest-Info: Profiles 20401 [Mar 31 2011] X-SpamTest-Method: none X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0285], KAS30/SDK/Release X-Anti-Virus: Kaspersky Mail Gateway, version: 5.6.28/RELEASE, bases: 20110331T110535 #5151353, check: 20120222 clean X-Spam-Score: -51.6 (---------------------------------------------------) X-Spam-Report: Spam detection software, running on the system "ollie.ringways.co.uk", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see Gary Stainburn for details. Content preview: Sorry, I missed one table. The users_facility_levels table is used to link the three tables listed below to give the lever per user/facility. On Wednesday 22 February 2012 11:18:23 Oliveiros d'Azevedo Cristina wrote: > Hi, Gary, > > I'm answering by editing your e-mail > ______ > > >I have three tables, > > > > users - all users of my web site > > facilities - facilities available on my web site > > facility_levels - access levels per user/facility. > > > > One of my facilities is a document library (f_id = 22) > > For this facility I have the levels > > > > select * from facility_levels where fl_f_id=22 order by fl_level; > > fl_f_id | fl_level | fl_desc > > ---------++ > > 22 | 1 | Read Only > > 22 | 2 | Add Versions > > 22 | 3 | Amend > > (3 rows) > > > > > > This sets the global access level for the Document Library per user. > > * It is not clear for me how this sets the global access level per user. > Shouldnt the facility_levels table have a u_id field, foreign key from > users table? And thus becoming an associative table between users and > facilities? > > > I now want to add authentication control on a document or folder level. > > For > > this I need to create a table library_document_user_level > > > > u_id - user id > > ld_id - library document id > > fl_level - level > > > > The foreign key constraint on fl_level needs to check facility_levels for > > fl_f_id = 22 as well as fl_level existing. > > * I may not be fully understanding your problem, but > library_document_user_level shouldn't have a field named fl_f_id, to > identify which facility the document/folder belongs to? > Had it such a field, you could do something like > FOREIGN_KEY (fl_f_id, fl_level) REFERENCES facility_levels (fl_f_id, > fl_level) > > > Just my two cents > > Best, > Oliveiros > > > I've googled this but can't find a suitable solution. Can anyone help > > please. > > -- > > Gary Stainburn > > Group I.T. Manager > > Ringways Garages > > http://www.ringways.co.uk > > > > -- > > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > > To make changes to your subscription: > > http://www.postgresql.org/mailpref/pgsql-sql [...] Content analysis details: (-51.6 points, 15.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -50 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 1.0 RING_SAFE RING_SAFE X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/76 X-Sequence-Number: 36369 Sorry, I missed one table. The users_facility_levels table is used to link the three tables listed below to give the lever per user/facility. On Wednesday 22 February 2012 11:18:23 Oliveiros d'Azevedo Cristina wrote: > Hi, Gary, > > I'm answering by editing your e-mail > ______ > > >I have three tables, > > > > users - all users of my web site > > facilities - facilities available on my web site > > facility_levels - access levels per user/facility. > > > > One of my facilities is a document library (f_id = 22) > > For this facility I have the levels > > > > select * from facility_levels where fl_f_id=22 order by fl_level; > > fl_f_id | fl_level | fl_desc > > ---------+----------+-------------- > > 22 | 1 | Read Only > > 22 | 2 | Add Versions > > 22 | 3 | Amend > > (3 rows) > > > > > > This sets the global access level for the Document Library per user. > > * It is not clear for me how this sets the global access level per user. > Shouldnt the facility_levels table have a u_id field, foreign key from > users table? And thus becoming an associative table between users and > facilities? > > > I now want to add authentication control on a document or folder level. > > For > > this I need to create a table library_document_user_level > > > > u_id - user id > > ld_id - library document id > > fl_level - level > > > > The foreign key constraint on fl_level needs to check facility_levels for > > fl_f_id = 22 as well as fl_level existing. > > * I may not be fully understanding your problem, but > library_document_user_level shouldn't have a field named fl_f_id, to > identify which facility the document/folder belongs to? > Had it such a field, you could do something like > FOREIGN_KEY (fl_f_id,fl_level) REFERENCES facility_levels (fl_f_id, > fl_level) > > > Just my two cents > > Best, > Oliveiros > > > I've googled this but can't find a suitable solution. Can anyone help > > please. > > -- > > Gary Stainburn > > Group I.T. Manager > > Ringways Garages > > http://www.ringways.co.uk > > > > -- > > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > > To make changes to your subscription: > > http://www.postgresql.org/mailpref/pgsql-sql -- Gary Stainburn Group I.T. Manager Ringways Garages http://www.ringways.co.uk