国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 互联网 > 跟我一起学extjs5(28--加入模块和菜单定义[1建立数据库和表])

跟我一起学extjs5(28--加入模块和菜单定义[1建立数据库和表])

来源:程序员人生   发布时间:2014-10-10 08:00:01 阅读次数:2880次

跟我一起学extjs5(28--加入模块和菜单定义[1建立数据库和表])

        下面我们开始进入自定义系统的设计和各个组成部分的搭建工作。
        首先在sql server中建立数据库,这里的数据的名字我定义为extjs5,然后需要建立模块的定义表,这个表里将存着系统中所有模块的定义信息。为了能有个直观的前后台的互动,先把模块和菜单这二个部分加进去,可以把菜单数据组织好后发送到前台去进行展示。

        由于系统中的模块很多,需要分类,因此在先要设计一个“模块分组”的表,对于菜单也是一样,需要有一个“菜单分组”的表。
  • 模块分组表:_ModuleGroup
  • 模块表:_Module
  • 菜单分组表:_MenuGroup
  • 模块的菜单定义表:_MenuModule

一、数据库中建表


        四个表的关系如下图所示:

        下面是建表的语句:

CREATE TABLE [dbo].[_ModuleGroup]( [tf_moduleGroupId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_title] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_description] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_iconURL] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_remark] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK___ModuleGroup__08EA5793] PRIMARY KEY CLUSTERED ( [tf_moduleGroupId] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY], CONSTRAINT [_ModuleGroup_ix1] UNIQUE NONCLUSTERED ( [tf_title] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY]

CREATE TABLE [dbo].[_Module]( [tf_moduleId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_moduleGroupId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_moduleName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_title] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_description] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_requestMapping] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_iconURL] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_shortname] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL, [tf_englishname] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL, [tf_tableName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_primaryKey] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_nameFields] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_titleTpl] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL, [tf_codeField] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_orderField] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_dateField] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_yearField] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_monthField] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_seasonField] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_fileField] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_homepageTag] [int] NULL, [tf_isEnable] [bit] NOT NULL, [tf_hasBrowse] [bit] NOT NULL, [tf_hasInsert] [bit] NOT NULL, [tf_hasEdit] [bit] NOT NULL, [tf_hasDelete] [bit] NOT NULL, [tf_hasExec] [bit] NOT NULL, [tf_hasAuditing] [bit] NOT NULL, [tf_hasApprove] [bit] NOT NULL, [tf_hasPayment] [bit] NOT NULL, [tf_hasAddition] [bit] NOT NULL, [tf_isInlineOper] [bit] NULL CONSTRAINT [DF___Module__tf_isIn__1ED998B2] DEFAULT ((0)), [tf_allowInsertExcel] [bit] NOT NULL, [tf_allowEditExcel] [bit] NOT NULL, [tf_defaultOrderField] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_codeLevel] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_linkedModule] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL, [tf_hasChart] [bit] NOT NULL, [tf_canLimit] [bit] NOT NULL, [tf_isSystem] [bit] NOT NULL, [tf_searchCondOrder] [int] NULL, [tf_remark] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK___Module__1BFD2C07] PRIMARY KEY CLUSTERED ( [tf_moduleId] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY], CONSTRAINT [_Module_ix1] UNIQUE NONCLUSTERED ( [tf_moduleName] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY], CONSTRAINT [_Module_ix2] UNIQUE NONCLUSTERED ( [tf_title] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO USE [extjs5] GO ALTER TABLE [dbo].[_Module] WITH CHECK ADD CONSTRAINT [_Module_fk1] FOREIGN KEY([tf_moduleGroupId]) REFERENCES [dbo].[_ModuleGroup] ([tf_moduleGroupId]) ON UPDATE CASCADE



CREATE TABLE [dbo].[_MenuGroup]( [tf_menuGroupId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_title] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_description] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_glyph] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL, [tf_iconURL] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_remark] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL, [tf_expand] [bit] NULL, CONSTRAINT [PK___MenuGroup__1920BF5C] PRIMARY KEY CLUSTERED ( [tf_menuGroupId] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY], CONSTRAINT [_MenuGroup_ix1] UNIQUE NONCLUSTERED ( [tf_title] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY]

CREATE TABLE [dbo].[_MenuModule]( [tf_menuModuleId] [int] NOT NULL, [tf_menuGroupId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_moduleId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_orderId] [int] NULL, [tf_addSeparator] [bit] NULL, [tf_parentMenu] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL, [tf_title] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL, [tf_parentFilter] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK___MenuModule__2C3393D0] PRIMARY KEY CLUSTERED ( [tf_menuModuleId] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO USE [extjs5] GO ALTER TABLE [dbo].[_MenuModule] WITH CHECK ADD CONSTRAINT [_MenuModule_fk1] FOREIGN KEY([tf_menuGroupId]) REFERENCES [dbo].[_MenuGroup] ([tf_menuGroupId]) ON UPDATE CASCADE GO ALTER TABLE [dbo].[_MenuModule] WITH CHECK ADD CONSTRAINT [_MenuModule_fk2] FOREIGN KEY([tf_moduleId]) REFERENCES [dbo].[_Module] ([tf_moduleId]) ON UPDATE CASCADE

        建立表后加入一些数据:










        数据库和源码会在一个阶段结束的时候提供下载。


生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生