webyestem(伊莱博)票据管理(ver1.0)数据库设计

ylbtech-DatabaseDesgin:web-伊莱博-票据管理(ver-1.0)-数据库设计
 
1.A,数据库关系图

 

1.B,数据库设计脚本

 /App_Data/sql-basic.sql

View Code
use master
go
-- =============================================
-- DatabaseName:票据管理系统
-- pubdate:14:44 2012-12-3
-- author:YuanBo
-- =============================================
IF EXISTS (SELECT * 
       FROM   master..sysdatabases 
       WHERE  name = N'Bill')
    DROP DATABASE Bill
GO

CREATE DATABASE Bill
GO
use Bill

-------------begin库存管理--------------
go
-- =============================================
-- Table:1,票据种类表
-- =============================================
create table BillType
(
billTypeId int primary key identity(1,1),    --编号【PK】
billTypeName varchar(200) not null,        --票据种类名称
pageSum int,        --每本页数
billLength int        --票据编号长度
)

go
-- =============================================
-- Table:2,票据表
-- =============================================
create table Bill
(
billId int primary key identity(1,1),    --编号【PK】
startNumbers int,            --起始编号
endNumbers int,                --结束编号
pubdate datetime default(getdate()),    --入库时间
versionNumbers int,            --版本编号

quantity int,        --数目【本】
billTypeId int        --票据种类编号【FK于BillType】【FK】
)
-------------end库存管理--------------



-------------begin用户模块--------------
go
-- =============================================
-- Table:1,用户权限分类
-- =============================================
create table UserClassification
(
userClassificationId int primary key identity(1,1),    --编号【PK】
userClassificationName varchar(100) not null        --名称
)

go
-- =============================================
-- Table:2,用户权限分类
-- =============================================
create table DescriptionTable
(
descriptionTableId int primary key identity(1,1),    --编号【PK】
descriptionTableName varchar(100) not null,        --名称
userClassificationId int             --【用户权限分类】编号【FK】
)

go
-- =============================================
-- Table:3,用户表
-- =============================================
create table Users
(
userId int primary key identity(1,1),    --编号【PK】
username varchar(100) unique,    --用户名【U】
pwd varchar(100),        --密码
role varchar(100),        --角色,【票据主管,普通用户】
)

go
-- =============================================
-- Table:4,“用户权限分类”与“用户权限分类”【第三方关系表】
-- =============================================
create table RoleList
(
userClassificationId int,    --【UserClassification】编号【FK】
descriptionTableId int,        --【DescriptionTable】编号【FK】
userId int            --【Users】编号【FK】
)
select * from sysobjects
1.C,功能实现代码

 /App_Data/select/1,BillType.sql

View Code
use Bill

go
-- =============================================
-- Model:库存管理模块
-- 1,对“票据种类表”操作
-- =============================================

go
--1,添加
insert into BillType(billTypeName,pageSum,billLength) values()


select billTypeName,pageSum,billLength from BillType

go
--2,查询所有
select billTypeId,billTypeName,pageSum,billLength from BillType
order by billTypeId asc

go
--3,修改一条
-billTypeName,pageSum,billLength
update BillType set billTypeName='',pageSum=0,billLength=0
where billTypeId=0

go
--4,删除一条
delete Bill where billTypeId=0
go
delete BillType where billTypeId=0


select * from BillType

 /App_Data/select/2,BillType.sql

View Code
use Bill

go
-- =============================================
-- Model:库存管理模块
-- 1,对“票据表”操作
-- =============================================
go
select * from Bill

go
--1,查询所有列表
--select billId,startNumbers,endNumbers,pubdate,versionNumbers,quantity,billTypeId from Bill

select billId,startNumbers,endNumbers,pubdate,versionNumbers,quantity,b.billTypeId from Bill b
inner join BillType bt on b.billTypeId=bt.billTypeId
warn 作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/ylbtech/p/2918313.html