• OA系统权限管理设计方案学习


    学习之:http://www.cnblogs.com/kivenhou/archive/2009/10/19/1586106.html

    此为模型图:

    image

    据此写了sql语句:

    drop table if exists tb_Permit_Group;
    drop table if exists tb_Position_Permit;
    drop table if exists tb_Position_User;
    drop table if exists tb_Project_User;
    drop table if exists tb_Role_Permit;
    drop table if exists tb_User_Permit;
    drop table if exists tb_User;
     
    drop table if exists tb_Permit;
    drop table if exists tb_Action;
     
    drop table if exists tb_Position;
    drop table if exists tb_Department;
    drop table if exists tb_Company;
     
    drop table if exists tb_Module;
     
    drop table if exists tb_Project;
     
    drop table if exists tb_Role;
     
     
    /*==============================================================*/
    /* Table: tb_Action                                             */
    /*==============================================================*/
    create table tb_Action
    (
       ActionCode           varchar(20) not null,
       ActionName           varchar(20),
       ActionValue          varchar(20),
       primary key (ActionCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Company                                            */
    /*==============================================================*/
    create table tb_Company
    (
       CompanyCode          varchar(20) not null,
       CompanyName          varchar(20),
       primary key (CompanyCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Department                                         */
    /*==============================================================*/
    create table tb_Department
    (
       DeptCode             varchar(20) not null,
       DeptName             varchar(20),
       ParentDepartment     varchar(20),
       DepartmentDescription varchar(256),
       CompanyCode          varchar(20),
       primary key (DeptCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Module                                             */
    /*==============================================================*/
    create table tb_Module
    (
       ModuleCode           varchar(20) not null,
       ModuleName           varchar(20),
       ModuleValue          varchar(20),
       LinkUrl              varchar(256),
       ParentModule         varchar(20),
       ModuleDescription    varchar(256),
       primary key (ModuleCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Permit                                             */
    /*==============================================================*/
    create table tb_Permit
    (
       PermitCode           varchar(100) not null,
       ModuleCode           varchar(20),
       ActionCode           varchar(20),
       PermitValue          varchar(20),
       primary key (PermitCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Permit_Group                                       */
    /*==============================================================*/
    create table tb_Permit_Group
    (
       GroupCode            varchar(20) not null,
       GroupName            varchar(20),
       PermitCode           varchar(100),
       primary key (GroupCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Position                                           */
    /*==============================================================*/
    create table tb_Position
    (
       PositionCode         varchar(100) not null,
       PositionName         varchar(20),
       PositionDescription  varchar(256),
       ParentPosition       varchar(20),
       DeptCode             varchar(20),
       primary key (PositionCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Position_Permit                                    */
    /*==============================================================*/
    create table tb_Position_Permit
    (
       PositionCode         varchar(100) not null,
       PermitCode           varchar(100),
       primary key (PositionCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Position_User                                      */
    /*==============================================================*/
    create table tb_Position_User
    (
       PositionCode         varchar(100),
       UserId               varchar(20)
    );
     
    /*==============================================================*/
    /* Table: tb_Project                                            */
    /*==============================================================*/
    create table tb_Project
    (
       ProjectCode          varchar(20) not null,
       ProjectName          varchar(20),
       ParentProject        varchar(20),
       ProjectDescription   varchar(256),
       primary key (ProjectCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Project_User                                       */
    /*==============================================================*/
    create table tb_Project_User
    (
       ProjectCode          varchar(20),
       UserId               varchar(20),
       IsLead               int
    );
     
    /*==============================================================*/
    /* Table: tb_Role                                               */
    /*==============================================================*/
    create table tb_Role
    (
       RoleCode             varchar(100) not null,
       RoleName             varchar(20),
       RoleDescription      varchar(256),
       primary key (RoleCode)
    );
     
    /*==============================================================*/
    /* Table: tb_Role_Permit                                        */
    /*==============================================================*/
    create table tb_Role_Permit
    (
       RoleCode             varchar(100) not null,
       PermitCode           varchar(100),
       primary key (RoleCode)
    );
     
    /*==============================================================*/
    /* Table: tb_User                                               */
    /*==============================================================*/
    create table tb_User
    (
       UserId               varchar(20) not null,
       UserName             varchar(20),
       Password             varchar(50),
       TrueName             varchar(12),
       DeptCode             varchar(20),
       primary key (UserId)
    );
     
    /*==============================================================*/
    /* Table: tb_User_Permit                                        */
    /*==============================================================*/
    create table tb_User_Permit
    (
       UserId               varchar(20),
       RoleCode             varchar(100),
       PositionCode         varchar(100),
       ProjectCode          varchar(20),
       PermitCode           varchar(100)
    );
     
    alter table tb_Department add constraint FK_Reference_5 foreign key (CompanyCode)
          references tb_Company (CompanyCode) on delete restrict on update restrict;
     
    alter table tb_Permit add constraint FK_Reference_3 foreign key (ModuleCode)
          references tb_Module (ModuleCode) on delete restrict on update restrict;
     
    alter table tb_Permit add constraint FK_Reference_4 foreign key (ActionCode)
          references tb_Action (ActionCode) on delete restrict on update restrict;
     
    alter table tb_Permit_Group add constraint FK_Reference_18 foreign key (PermitCode)
          references tb_Permit (PermitCode) on delete restrict on update restrict;
     
    alter table tb_Position add constraint FK_Reference_21 foreign key (DeptCode)
          references tb_Department (DeptCode) on delete restrict on update restrict;
     
    alter table tb_Position_Permit add constraint FK_Reference_19 foreign key (PermitCode)
          references tb_Permit (PermitCode) on delete restrict on update restrict;
     
    alter table tb_Position_Permit add constraint FK_Reference_9 foreign key (PositionCode)
          references tb_Position (PositionCode) on delete restrict on update restrict;
     
    alter table tb_Position_User add constraint FK_Reference_11 foreign key (PositionCode)
          references tb_Position (PositionCode) on delete restrict on update restrict;
     
    alter table tb_Position_User add constraint FK_Reference_6 foreign key (UserId)
          references tb_User (UserId) on delete restrict on update restrict;
     
    alter table tb_Project_User add constraint FK_Reference_22 foreign key (ProjectCode)
          references tb_Project (ProjectCode) on delete restrict on update restrict;
     
    alter table tb_Project_User add constraint FK_Reference_23 foreign key (UserId)
          references tb_User (UserId) on delete restrict on update restrict;
     
    alter table tb_Role_Permit add constraint FK_Reference_1 foreign key (RoleCode)
          references tb_Role (RoleCode) on delete restrict on update restrict;
     
    alter table tb_Role_Permit add constraint FK_Reference_17 foreign key (PermitCode)
          references tb_Permit (PermitCode) on delete restrict on update restrict;
     
    alter table tb_User add constraint FK_Reference_20 foreign key (DeptCode)
          references tb_Department (DeptCode) on delete restrict on update restrict;
     
    alter table tb_User_Permit add constraint FK_Reference_12 foreign key (UserId)
          references tb_User (UserId) on delete restrict on update restrict;
     
    alter table tb_User_Permit add constraint FK_Reference_13 foreign key (RoleCode)
          references tb_Role (RoleCode) on delete restrict on update restrict;
     
    alter table tb_User_Permit add constraint FK_Reference_14 foreign key (PositionCode)
          references tb_Position (PositionCode) on delete restrict on update restrict;
     
    alter table tb_User_Permit add constraint FK_Reference_15 foreign key (ProjectCode)
          references tb_Project (ProjectCode) on delete restrict on update restrict;
     
    alter table tb_User_Permit add constraint FK_Reference_16 foreign key (PermitCode)
          references tb_Permit (PermitCode) on delete restrict on update restrict;
  • 相关阅读:
    ioremap函数
    kmalloc、kzalloc和vmalloc
    C语言 snprintf函数
    C语言 memset函数
    消息队列
    mount -a
    linux系统查看服务状态和启动停止服务
    Java中创建对象的内存图
    Java中数组在内存中的图解
    socket编程(Java实现)
  • 原文地址:https://www.cnblogs.com/luhouxiang/p/4909991.html
Copyright © 2020-2023  润新知