title: Zend_Acl, with roles and permissions stored in database
body: <p>i want to build an ACL system for my application which have the following requirement.</p>
  
  <ol>
  <li>Users will be assigned single or multiple role. (Admin, Staff) etc.</li>
  <li>Role will have permissions.(Send_Invoices, Send_mail, Delete_Invoices, Send_Estimate) etc.</li>
  <li>User will be assigned custom permission apart from the role it inherits.</li>
  </ol>
  
  <p>my database structure for ACL is as follows</p>
  
  <pre><code>role:
  +----------+-------------+------+-----+---------+----------------+
  | Field    | Type        | Null | Key | Default | Extra          |
  +----------+-------------+------+-----+---------+----------------+
  | id       | int(11)     | NO   | PRI | NULL    | auto_increment |
  | roleName | varchar(50) | NO   | UNI | NULL    |                |
  +----------+-------------+------+-----+---------+----------------+
  permission:
  +----------------+-------------+------+-----+---------+----------------+
  | Field          | Type        | Null | Key | Default | Extra          |
  +----------------+-------------+------+-----+---------+----------------+
  | id             | int(11)     | NO   | PRI | NULL    | auto_increment |
  | permissionName | varchar(50) | NO   |     | NULL    |                |
  | permissionKey  | varchar(50) | NO   | UNI | NULL    |                |
  +----------------+-------------+------+-----+---------+----------------+
  role_permission
  +---------------+---------+------+-----+---------+----------------+
  | Field         | Type    | Null | Key | Default | Extra          |
  +---------------+---------+------+-----+---------+----------------+
  | id            | int(11) | NO   | PRI | NULL    | auto_increment |
  | role_id       | int(11) | NO   | MUL | NULL    |                |
  | permission_id | int(11) | NO   |     | NULL    |                |
  +---------------+---------+------+-----+---------+----------------+
  user_role
  +---------------+---------+------+-----+---------+----------------+
  | Field         | Type    | Null | Key | Default | Extra          |
  +---------------+---------+------+-----+---------+----------------+
  | id            | int(11) | NO   | PRI | NULL    | auto_increment |
  | user_id       | int(11) | NO   | MUL | NULL    |                |
  | role_id       | int(11) | NO   |     | NULL    |                |
  +---------------+---------+------+-----+---------+----------------+
  user_permission
  +---------------+---------+------+-----+---------+----------------+
  | Field         | Type    | Null | Key | Default | Extra          |
  +---------------+---------+------+-----+---------+----------------+
  | id            | int(11) | NO   | PRI | NULL    | auto_increment |
  | user_id       | int(11) | NO   | MUL | NULL    |                |
  | permission_id | int(11) | NO   |     | NULL    |                |
  +---------------+---------+------+-----+---------+----------------+
  </code></pre>
  
  <p>i have migrated to Zend Framework, and having problem deciding wether Zend_Acl allows me to implement the current structure. my question is.</p>
  
  <ol>
  <li>is it possible for me to implement the ACL with current database structure to do the needful in Zend Framework?</li>
  <li>is there any better implementation that could allow me to achieve what i want in zend framework?</li>
  </ol>
  
  <p>i will be grateful if someone could provide me a way to get started with what i need to do. any resources, links that could help me?</p>
  
  <p>thank you.</p>