• 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;
  • 相关阅读:
    URLEncoder编码算法
    传输层TCP和UDP的区别分析与应用场景
    【Android】AndroidStudio打包apk出现的一些问题 `Error:Execution failed for task ':app:lintVitalRelease'.
    【Android】在开发项目的时候,利用AndroidStudio开发工具,突然一直报错。
    【Android】listview 嵌套gridview报错,代码:”during second layout pass: posting in next frame
    华为荣耀5X(畅玩版 全网通)USB调试模式如何开启教程(开发者模式 开发者选项打开)
    Android开发之制作圆形头像自定义View,直接引用工具类,加快开发速度。带有源代码学习
    AndroidStudio中利用git下载github或者git.oschina的代码时报错:repository test has failed解决方法
    java最简单的知识之创建一个简单的windows窗口,利用Frame类
    【Android】java生成炫酷验证码,不区分大小写。登陆,发送手机验证码,防止注册机,android开发
  • 原文地址:https://www.cnblogs.com/luhouxiang/p/4909991.html
Copyright © 2020-2023  润新知