CREATE TABLE Prinicpals (
        id int auto_increment 
        PrincipalType VARCHAR(16) not_null,
        PrincipalId int # foreign key to Users or Groups, depending
)

CREATE TABLE Groups (
        id int auto_increment,
        Domain varchar(255), 
        Instance varchar(16),
        Name varchar(255),
        Description varchar(255),
);
CREATE TABLE ACL (
  id INTEGER NOT NULL  AUTO_INCREMENT,
  Principal integer NULL  , #Foreign key to principals
  RightName varchar(25) NULL  ,
  RightDomain varchar(25) NULL  ,
  RightInstance integer NULL  ,
  PRIMARY KEY (id)
);      

CREATE TABLE GroupMembers (
        id int auto_increment,
        Group int, # foreign key to Principals
        Member int # foreign key to Principals
)

create table GroupMembersCache (
        id int auto_increment,
        Group int, # foreign key to Principals
        Member int, # foreign key to Principals
        Via int, #foreign key to g_m_u
)

insert into principals values ('bubbles);
insert into principals values ('fubar');
insert into principals values ('sheeri');
insert into principals values ('sgw');

insert into principals values ('staff');
insert into principals values ('sysadmin');
insert into principals values ('senior admin');


insert into group_members values(1, 'staff', 'bubbles');
insert into group_members values(2, 'sysadmin', 'sheeri');
insert into group_members values(3,'senior admin', 'sgw');
insert into group_members values(4,'senior admin', 'fubar');
insert into group_members values(5, 'sysadmin', 'senior admin')
        
Groups


      
Domain          Queues
Instance        <queueid#>
Name            AdminCc, Cc

/Queues/1/AdminCc
/Queues/3/Cc

Domain          Tickets
Instance        <#n>
Name            Owner, Requestor, Cc, AdminCc

/Tickets/1/Owner
/Tickets/1/Requestor
/Tickets/1/Cc
       Has members: /Queues/whatever queue the ticket has/Cc 
/Tickets/1/AdminCc
       Has members: /Queues/whatever queue the ticket has/AdminCc 


Domain          Users
Instance        <userid>

/Users/1/MyDelegates
/Users/1/MyOtherDelegates


Domain          System
Name            Admins, AdminManagers

/System/Administrators
/System/Blah


