ylbtech-Recode(记录)-数据库设计
2015-01-12 17:40
211 查看
ylbtech-dbs:ylbtech-Recode(记录)-数据库设计 |
-- DatabaseName:Recode
-- desc:记录(生活记录)
-- 创作思路:历史不能修改,但可以修正,追溯演变历程。
-- pubdate:16:46 2015/1/12
-- author:ylbtech
-- =============================================
1.A,数据库关系图(Database Diagram) 返回顶部 |
1.B,数据库设计脚本(Database Design Script)返回顶部 |
-- ============================================= -- DatabaseName:Recode -- desc:记录(生活记录) -- 创作思路:历史不能修改,但可以修正,追溯演变历程。 -- pubdate:16:46 2015/1/12 -- author:ylbtech -- ============================================= USE master GO -- Drop the database if it already exists IF EXISTS ( SELECT name FROM sys.databases WHERE name = N'Recode' ) DROP DATABASE Recode GO CREATE DATABASE Recode go use Recode GO -- ============================================= -- ylb:类别表 -- desc: -- ============================================= create table Category ( categoryId uniqueidentifier primary key, --编号 categoryName varchar(200), --类别 flagVisible bit --是否启用 ) go go -- ============================================= -- opt:1,添加类别 -- ============================================= -- insert into Category(categoryId,categoryName,flagVisible) values('','未分类',0) go -- ============================================= -- opt:1,查看类别列表 -- ============================================= select categoryId,categoryName,flagVisible from Category order by categoryName go -- ============================================= -- ylb:记录表 -- desc:记录、记录版本历史 -- 2)只允许修改一级记录、不许修改历史记录 -- ============================================= create table Recode ( recodeId int identity(1,1) primary key, --编号 content varchar(2000), --内容 pubdate datetime default(getdate()), --发布日期 endEditDate datetime, --最后修改日期 flagBase int, -- 0:一级:其他二级(即上级单位编号) categoryId uniqueidentifier references Category(categoryId) --类别编号【FK】 ) go -- ============================================= -- opt:1,添加记录 -- ============================================= -- insert into Recode(content,pubdate,flagBase,categoryId) values('Hi, Rain','2015-1-12',0,'') go -- ============================================= -- opt:2,修改记录并添加备注(修改原记录内容、更新最后修改日期,同时插入修改备注) -- ============================================= -- update Recode set content='Hi,Gr rain',endEditDate=getdate() where recode='101' go -- insert into Recode(content,pubdate,flagBase,categoryId) values('Hi, Rain','2015-1-12',101,'') go -- ============================================= -- opt:3,记录列表 -- ============================================= select recodeId,content,pubdate,endEditDate,flagBase,categoryId from Recode where flagBase=0 order by recodeId go -- ============================================= -- opt:3.2,记录修改备注列表 -- ============================================= select recodeId,content,pubdate,endEditDate,flagBase,categoryId from Recode where flagBase=101 order by recodeId
View Code
1.B.2,
1.C,功能实现代码(Function Implementation Code)返回顶部 |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
相关文章推荐
- 常见数据库设计(2)——历史数据问题之单记录变更
- ylbtech-SubwayNav(地铁线路导航)-数据库设计
- 数据库设计学习记录
- 数据库表设计--备份记录的表设计优化
- 【实训记录】山东大学场馆管理系统实训笔记之——数据库设计
- 如何在R5c/s下设计数据库:读取Excel中的记录并批量产生表单
- 关于聊天记录数据库表结构设计
- 学生信息综合管理系统开发记录(数据库课程设计)
- ylbtech-Bill(发票管理)-数据库设计
- 从简到繁——SSM个人博客搭建完全记录【1】开发环境搭建和数据库表设计
- ylbtech-cnblogs(博客园)-数据库设计-1,Passport(账户)
- ylbtech-数据库设计与优化-对作为复选框/单选列表的集合表的设计
- ylbtech-cnblogs(博客园)-数据库设计-7,News(新闻)
- 数据库设计过程遇到的零散点记录powerdesigner 数据库设计 表设计
- 2014.02.19 系统操作记录 数据库表的设计
- 常见数据库设计(3)——历史数据问题之多记录变更
- ylbtech-cnblogs(博客园)-数据库设计-2,Admin(用户后台)-用户自定义参数设置
- 设计数据库字段经常会使用1,2,3来代表数据记录的状态
- 《全国计算机等级考试三级教程》章节学习记录——第三章.数据库结构设计
- 用JAVA如何实现每天1亿条记录的数据存储,数据库方面怎么设计?