sql - Tree Structure and Recursion -


Using a PostgreSQL 8.4.14 database, I have an example such as representing a tree structure:

create table unit (id bilton null primary key, name varchar (64) tap, parent_id big, foreign key (parent_ID) reference unit (id)); INSERT (1, 'parent', NULL) in unit value, (2, 'child', 1), (3, 'grandson, a', 2), (4, 'grandson, b', 2);
  id | Name | Parent_id ---- + -------------- + ----------- 1 | Parents 2 | Children 1 3 | Grandson a | 2 4 | I want to create an access control list for those units, where each unit has its own ACL, or it should be inherited from the nearest ancestor with its ACL.  
  create table ACL (Unit_ID bentunt faucet primary key, foreign key (unit_id) reference unit (ID)); Insert in ACL Value (1), (4);   
  unit_ id --------- 1 4   

I am To determine whether a unit is receiving ACL from the predecessor, using:

  create view as inheriting_acl u Id as unit_id is inheriting the unit in the form of COUNT (a. *) = 0, such as leaving u as an AL.l. on.unit_id = u.id GROUP BY u.id;   

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -