OA 办公系统 模块设计
--連接主數(shù)據(jù)庫 use Master go --如果數(shù)據(jù)庫simpleoa 存在,則先刪除simpleoa。 if exists (select * from sysdatabases where name='simpleoa') drop database simpleoa go--創(chuàng)建simpleoa數(shù)據(jù)庫 create database simpleoa go-- use simpleoa go--創(chuàng)建用戶表 create table [dbo].[User] ([UserID] int Identity(1,1) not null,--用戶ID[UserLoginName] nvarchar(20) not null, --用戶登錄名[UserName] nvarchar(20) not null, --用戶姓名[UserPassword] nvarchar(20) not null, --用戶密碼[UserRegister] nvarchar(20) default getdate(), --用戶注冊時間[UserUp] bit default 'true', --是否需要上交[UserInfo] nvarchar(200) not null --備注 -- ) alter table [dbo].[User] add constraint pk_user primary key(UserID); go--創(chuàng)建部門表 create table [dbo].[Department] ([DepartmentID] [int] identity(1,1) not null, --部門ID[DepartmentNum] [nvarchar](20) not null, --部門編號[DepartmentName] [nvarchar](20) not null, --部門名稱[UserID] [int] not null, --部門負(fù)責(zé)人ID[DepartmentInfo] [nvarchar](200) not null --部門備注 ) alter table [dbo].[Department] add constraint pk_department primary key(DepartmentID); go --添加外鍵約束 --alter table Department add constraint dep_ref_use foreign key(UserID) references [dbo].[User](UserID) --go--創(chuàng)建消息表 create table [dbo].[Message] ([MessageID] [int] identity(1,1) not null, --消息ID[MessageSender] [int] not null, --外鍵[MessageSubject] [nvarchar](50) default getdate(), --消息主題[MessageBody] [nvarchar](500) not null, --消息內(nèi)容[MessageDataTime] [datetime] default getdate(), --發(fā)送消息時間[MessageAttachment] [bit] default 'false' --是否含有附件 ) alter table [dbo].[Message] add constraint pk_MessageID primary key (MessageID); go --消息接收人表: create table [dbo].[Recipient] ([RecipientID] [int] identity(1,1) not null, --接收人ID[MessageID] [int] not null, --外鍵[RecipientRead] [bit] not null, --是否讀過[RecipientDel] [bit] not null, --是否刪除(顯示在已刪除消息欄)[RecipientReadTime] [nvarchar](20) default '尚未閱讀', --客戶要求能看到接收人是否已經(jīng)看過。[RecipientDelTime] [nvarchar](20) default '尚未刪除', --儲存刪除消息時間[RecipientAllDel] [nvarchar](20) default '尚未徹底刪除'--不再顯示在已刪除消息欄 ) alter table [dbo].[Recipient] add constraint pk_recipient primary key(RecipientID); go --附件表 create table [dbo].[Attachment] (AttachmentID [int] identity(1,1), --附件IDAttachmentName [nvarchar](50) not null, --附件名稱AttachmentFilePath [nvarchar](100) not null, --附件存放類型AttachmentType [nvarchar](20) not null, --附件文件類型AttachmentDateTime [datetime] not null, --附件上傳時間AttachmentSource [nvarchar](20) not null, --附件來源:消息、文章、上交?AttachmentSourceID [int] not null, --附件來源ID ) alter table [dbo].[Attachment] add constraint pk_Attachment primary key(AttachmentID) go--每月上傳時間表 create table [dbo].[Time] (TimeID [int] identity(1,1), --表時間IDTimeName [nvarchar](20) not null, --時間變量名TimeContent [datetime] default getdate() --時間變量值 ) alter table [dbo].[Time] add constraint pk_timeid primary key(TimeID) go 代碼 --連接主數(shù)據(jù)庫
use Master
go
--如果數(shù)據(jù)庫simpleoa 存在,則先刪除simpleoa。
if exists (select * from sysdatabases where name='simpleoa')
drop database simpleoa
go
--創(chuàng)建simpleoa數(shù)據(jù)庫
create database simpleoa
go
--
use simpleoa
go
--創(chuàng)建用戶表
create table [dbo].[User]
(
[UserID] int Identity(1,1) not null,--用戶ID
[UserLoginName] nvarchar(20) not null, --用戶登錄名
[UserName] nvarchar(20) not null, --用戶姓名
[UserPassword] nvarchar(20) not null, --用戶密碼
[UserRegister] nvarchar(20) default getdate(), --用戶注冊時間
[UserUp] bit default 'true', --是否需要上交
[UserInfo] nvarchar(200) not null --備注 --
)
alter table [dbo].[User] add constraint pk_user primary key(UserID);
go
--創(chuàng)建部門表
create table [dbo].[Department]
(
[DepartmentID] [int] identity(1,1) not null, --部門ID
[DepartmentNum] [nvarchar](20) not null, --部門編號
[DepartmentName] [nvarchar](20) not null, --部門名稱
[UserID] [int] not null, --部門負(fù)責(zé)人ID
[DepartmentInfo] [nvarchar](200) not null --部門備注
)
alter table [dbo].[Department] add constraint pk_department primary key(DepartmentID);
go
--添加外鍵約束
--alter table Department add constraint dep_ref_use foreign key(UserID) references [dbo].[User](UserID)
--go
--創(chuàng)建消息表
create table [dbo].[Message]
(
[MessageID] [int] identity(1,1) not null, --消息ID
[MessageSender] [int] not null, --外鍵
[MessageSubject] [nvarchar](50) default getdate(), --消息主題
[MessageBody] [nvarchar](500) not null, --消息內(nèi)容
[MessageDataTime] [datetime] default getdate(), --發(fā)送消息時間
[MessageAttachment] [bit] default 'false' --是否含有附件
)
alter table [dbo].[Message] add constraint pk_MessageID primary key (MessageID);
go
--消息接收人表:
create table [dbo].[Recipient]
(
[RecipientID] [int] identity(1,1) not null, --接收人ID
[MessageID] [int] not null, --外鍵
[RecipientRead] [bit] not null, --是否讀過
[RecipientDel] [bit] not null, --是否刪除(顯示在已刪除消息欄)
[RecipientReadTime] [nvarchar](20) default '尚未閱讀', --客戶要求能看到接收人是否已經(jīng)看過。
[RecipientDelTime] [nvarchar](20) default '尚未刪除', --儲存刪除消息時間
[RecipientAllDel] [nvarchar](20) default '尚未徹底刪除'--不再顯示在已刪除消息欄
)
alter table [dbo].[Recipient] add constraint pk_recipient primary key(RecipientID);
go
--附件表
create table [dbo].[Attachment]
(
AttachmentID [int] identity(1,1), --附件ID
AttachmentName [nvarchar](50) not null, --附件名稱
AttachmentFilePath [nvarchar](100) not null, --附件存放類型
AttachmentType [nvarchar](20) not null, --附件文件類型
AttachmentDateTime [datetime] not null, --附件上傳時間
AttachmentSource [nvarchar](20) not null, --附件來源:消息、文章、上交?
AttachmentSourceID [int] not null, --附件來源ID
)
alter table [dbo].[Attachment] add constraint pk_Attachment primary key(AttachmentID)
go
--每月上傳時間表
create table [dbo].[Time]
(
TimeID [int] identity(1,1), --表時間ID
TimeName [nvarchar](20) not null, --時間變量名
TimeContent [datetime] default getdate() --時間變量值
)
alter table [dbo].[Time] add constraint pk_timeid primary key(TimeID)
go
?
最近偶然接到這樣一個小項(xiàng)目,所以認(rèn)真做一下。1,消息模塊設(shè)計:
?
???? 方案一:A給B,C,D發(fā)送信息,則在消息表中生成3條信息,接收人分別是B,C,D,并有Bool表示是否查看過。
???? 方案二:A給B,C,D發(fā)送信息,在表A中生成一條信息?,表B中保存消息ID,和接收人分別是B,C,D的3條信息。(優(yōu)點(diǎn),當(dāng)消息字?jǐn)?shù)多時,能有效節(jié)省數(shù)據(jù)庫空間)
???? 關(guān)于消息附件:設(shè)計表FuJianBiao ,每個附件記錄引用消息表ID,可實(shí)現(xiàn)一條消息附帶多條附件。
?
2,用戶及權(quán)限模塊設(shè)計:
????
?
用戶角色表關(guān)聯(lián)用戶表和角色表,角色功能表關(guān)聯(lián)角色表和功能表,都是多對多關(guān)系。每個用戶有多個角色,每個角色也有多個用戶;每個角色有多個功能,每個功能可以對應(yīng)多個角色,由于該項(xiàng)目對權(quán)限要求明確而且很簡單,所以不必這樣設(shè)計用戶權(quán)限系統(tǒng)。簡單合適就好。
?
3,部門管理模塊(管理員)設(shè)計
設(shè)計部門表
?
4,文檔上傳管理模塊:
?
?
5,服務(wù)器文件管理模塊:
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/netact/archive/2010/12/08/1900568.html
總結(jié)
以上是生活随笔為你收集整理的OA 办公系统 模块设计的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 设计原则(6):开闭原则
- 下一篇: 雷鸟安装的插件