数据库设计

数据库工具使用sqlserver2014

数据库名称:RightDb

文件路径默认

用户名sa 密码自定义

UserInfos 用户表

UserId   UserName   UserPwd

RoleInfos 角色表

RoleId   RoleName   Remark

MenuInfos 菜单表

MenuId   MenuName   ParentId  FrmName   MKey

UserRoleInfos 用户角色关系表

URId  UserId  RoleId

RoleMenuInfos 角色菜单关系表

RMId  MenuId  RoleId

数据库脚本代码

 

USE [master]
GO
/****** Object:  Database [RightDb]    Script Date: 2020-06-08 14:32:29 ******/
CREATE DATABASE [RightDb]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'RightDb', FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\RightDb.mdf' , SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'RightDb_log', FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\RightDb_log.ldf' , SIZE = 2048KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [RightDb] SET COMPATIBILITY_LEVEL = 120
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [RightDb].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [RightDb] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [RightDb] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [RightDb] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [RightDb] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [RightDb] SET ARITHABORT OFF 
GO
ALTER DATABASE [RightDb] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [RightDb] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [RightDb] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [RightDb] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [RightDb] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [RightDb] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [RightDb] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [RightDb] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [RightDb] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [RightDb] SET  DISABLE_BROKER 
GO
ALTER DATABASE [RightDb] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [RightDb] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [RightDb] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [RightDb] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [RightDb] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [RightDb] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [RightDb] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [RightDb] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [RightDb] SET  MULTI_USER 
GO
ALTER DATABASE [RightDb] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [RightDb] SET DB_CHAINING OFF 
GO
ALTER DATABASE [RightDb] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [RightDb] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
ALTER DATABASE [RightDb] SET DELAYED_DURABILITY = DISABLED 
GO
USE [RightDb]
GO
/****** Object:  Table [dbo].[MenuInfos]    Script Date: 2020-06-08 14:32:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MenuInfos](
	[MenuId] [int] IDENTITY(1,1) NOT NULL,
	[MenuName] [varchar](50) NULL,
	[ParentId] [int] NULL,
	[FrmName] [varchar](50) NULL,
	[MKey] [varchar](50) NULL,
 CONSTRAINT [PK_MenuInfos] PRIMARY KEY CLUSTERED 
(
	[MenuId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[RoleInfos]    Script Date: 2020-06-08 14:32:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[RoleInfos](
	[RoleId] [int] IDENTITY(1,1) NOT NULL,
	[RoleName] [varchar](50) NULL,
	[Remark] [varchar](500) NULL,
	[IsAdmin] [tinyint] NOT NULL CONSTRAINT [DF_RoleInfos_IsAdmin]  DEFAULT ((0)),
 CONSTRAINT [PK_RoleInfos] PRIMARY KEY CLUSTERED 
(
	[RoleId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[RoleMenuInfos]    Script Date: 2020-06-08 14:32:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[RoleMenuInfos](
	[RMId] [int] IDENTITY(1,1) NOT NULL,
	[RoleId] [int] NULL,
	[MenuId] [int] NULL,
 CONSTRAINT [PK_RoleMenuInfos] PRIMARY KEY CLUSTERED 
(
	[RMId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[UserInfos]    Script Date: 2020-06-08 14:32:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[UserInfos](
	[UserId] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [varchar](50) NULL,
	[UserPwd] [varchar](50) NULL,
 CONSTRAINT [PK_UserInfos] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[UserRoleInfos]    Script Date: 2020-06-08 14:32:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UserRoleInfos](
	[URId] [int] IDENTITY(1,1) NOT NULL,
	[UserId] [int] NULL,
	[RoleId] [int] NULL,
 CONSTRAINT [PK_UserRoleInfos] PRIMARY KEY CLUSTERED 
(
	[URId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
USE [master]
GO
ALTER DATABASE [RightDb] SET  READ_WRITE 
GO