NESC SQL Server Database Design, Code and Development Standards
目录
1.更改历史...................................................................................................................................................4
2. 简介..........................................................................................................................................................5
3. 开发环境..................................................................................................................................................6
3.1 数据库模型 ........................................................................................................................................6
3.2 DIAGRAMS ..........................................................................................................................................6
3.3 版本控制............................................................................................................................................6
3.4 源码目录结构 ....................................................................................................................................6
4.物理数据库模型&字典.........................................................................................................................8
4.1 物理数据模型 ....................................................................................................................................8
4.2 IDEF1X 方法 .....................................................................................................................................8
4.3 物理数据库数据字典 ........................................................................................................................9
4.4 性能设计............................................................................................................................................9
4.5 SQL SERVER DATA BAS E,FILE AND FILEGROUP..................................................................................10
4.5.1
数据库
.......................................................................................................................................10
4.5.2
数据文件和日志文件
...............................................................................................................10
4.5.3
文件组
.......................................................................................................................................10
5.命名协定..............................................................................................................................................10
名字中的空格
........................................................................................................................................11
用于命名的标准字符............................................................................................................................11
5.1 数据库命名原则及版本控制 ..........................................................................................................12
5.2 SERVER/命名实例的命名.................................................................................................................12
5.3 数据库命名 .....................................................................................................................................12
5.4 缩写规范..........................................................................................................................................14
5.5 数据库对象—表,视图,列名,约束,规则,默认值...............................................................14
5.6 列名..................................................................................................................................................15
5.7 存储过程命名 ..................................................................................................................................17
5.8 游标命名..........................................................................................................................................17
5.9 触发器命名 ......................................................................................................................................17
5.10 索引命名........................................................................................................................................18
5.11 主键和外键命名 ............................................................................................................................18
5.12 CHECK约束命名.............................................................................................................................18
5.13 源文件命名....................................................................................................................................19
5.14 JOB的命名......................................................................................................................................19
5.15 用户自定义函数命名 ....................................................................................................................19
5.16 用户自定义数据类型命名 ............................................................................................................19
5.17 复制命名........................................................................................................................................20
5.18 局部变量命名标准........................................................................................................................20
6. SQL SERVER代码规范 ......................................................................................................................21
6.1 对象创建脚本 ..................................................................................................................................21
6.2 数据库更改脚本..............................................................................................................................22
6.3 综合开发实践 ..................................................................................................................................24
6.4 格式化T-SQL代码 ..........................................................................................................................25
6.4.1
保持单行字符少于
87
个
.........................................................................................................25
6.4.2 Case...........................................................................................................................................25
6.4.3
缩进间距
...................................................................................................................................25
6.4.4
排列
CASE
和相应的
END
语句
..................................................................................................25
6.4.5 IF
和
WHILE...............................................................................................................................26
Version 1.0 Final May. 2005