Introduction This document s purpose is to define Microsoft SQL server database design standards.



Similar documents
Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

How To Create A Table In Sql (Ahem)

Introduction to Triggers using SQL

Using SQL Server Management Studio

Database Design Standards. U.S. Small Business Administration Office of the Chief Information Officer Office of Information Systems Support

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

SQL Server An Overview


SQL Server Table Design - Best Practices

Managing Objects with Data Dictionary Views. Copyright 2006, Oracle. All rights reserved.

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

IT2305 Database Systems I (Compulsory)

Fundamentals of Database Design

Conventional Files versus the Database. Files versus Database. Pros and Cons of Conventional Files. Pros and Cons of Databases. Fields (continued)

Design and Implementation

3.GETTING STARTED WITH ORACLE8i

4 Simple Database Features

Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

TIM 50 - Business Information Systems

MS SQL Performance (Tuning) Best Practices:

IT2304: Database Systems 1 (DBS 1)

A Brief Introduction to MySQL

Guide to Upsizing from Access to SQL Server

Oracle Database 10g Express

Oracle Database Development Standards For DNR Staff and Contractors. Table of Contents

Exploring Microsoft Office Access Chapter 2: Relational Databases and Multi-Table Queries

CSCE 156H/RAIK 184H Assignment 4 - Project Phase III Database Design

Ontrack PowerControls V8.1 for SQL ReadMe

SQL NULL s, Constraints, Triggers

ATTACHMENT 6 SQL Server 2012 Programming Standards

Database Design and Database Programming with SQL - 5 Day In Class Event Day 1 Activity Start Time Length

Cello How-To Guide. Pickup List Management

Division of IT Security Best Practices for Database Management Systems

HP Quality Center. Upgrade Preparation Guide

Guide to SQL Programming: SQL:1999 and Oracle Rdb V7.1

SQL Server. 1. What is RDBMS?

Customer Bank Account Management System Technical Specification Document

A basic create statement for a simple student table would look like the following.

Instant SQL Programming

Section of DBMS Selection & Evaluation Questionnaire

Creating Database Tables in Microsoft SQL Server

CA IDMS SQL. Programming Guide. Release

Chancery SMS Database Split

Select the Crow s Foot entity relationship diagram (ERD) option. Create the entities and define their components.

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

BCA. Database Management System

Schema Evolution in SQL-99 and Commercial (Object-)Relational DBMS

Database Migration : An In Depth look!!

Fine Grained Auditing In Oracle 10G

Ontrack PowerControls User Guide Version 8.0

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

Simba Apache Cassandra ODBC Driver

Database Programming with PL/SQL: Learning Objectives

Databasesystemer, forår 2005 IT Universitetet i København. Forelæsning 3: Business rules, constraints & triggers. 3. marts 2005

AV-005: Administering and Implementing a Data Warehouse with SQL Server 2014

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Oracle Database: SQL and PL/SQL Fundamentals

ICAB4136B Use structured query language to create database structures and manipulate data

MySQL for Beginners Ed 3

Beginning C# 5.0. Databases. Vidya Vrat Agarwal. Second Edition

SQL Data Definition. Database Systems Lecture 5 Natasha Alechina

[MS-WSSDM]: Windows SharePoint Services: Content Database Data Migration Communications Protocol Specification

Preview DESIGNING DATABASES WITH VISIO PROFESSIONAL: A TUTORIAL

Data Modeling Basics

DbSchema Tutorial with Introduction in SQL Databases

A Rational Software Whitepaper

Toad for Data Analysts, Tips n Tricks

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Fundamentals of Database System

Performance Management of SQL Server

Best Approaches to Database Auditing: Strengths and Weaknesses.

ERserver. DB2 Universal Database for iseries SQL Programming with Host Languages. iseries. Version 5

The Relational Model. Why Study the Relational Model?

Websense SQL Queries. David Buyer June 2009

Database Systems. S. Adams. Dilbert. Available: Hans-Petter Halvorsen, M.Sc.

Virtual Private Database Features in Oracle 10g.

Evaluation of Sub Query Performance in SQL Server

SES Project v 9.0 SES/CAESAR QUERY TOOL. Running and Editing Queries. PS Query

Migrate Topaz databases from One Server to Another

KB_SQL SQL Reference Guide Version 4

1 File Processing Systems

Files. Files. Files. Files. Files. File Organisation. What s it all about? What s in a file?

Optimum Database Design: Using Normal Forms and Ensuring Data Integrity. by Patrick Crever, Relational Database Programmer, Synergex

5. CHANGING STRUCTURE AND DATA

Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.

ODBC Client Driver Help Kepware, Inc.

New SQL Features in Firebird 3

SQL Server 2008 Administration

Developing Web Applications for Microsoft SQL Server Databases - What you need to know

Oracle Database: SQL and PL/SQL Fundamentals NEW

DATABASE ADMINISTRATION SQL SERVER STANDARDS

Backup and Recovery in MS SQL Server. Andrea Imrichová

Driver for JDBC Implementation Guide

Working with DB2 UDB objects

CS143 Notes: Views & Authorization

EECS 647: Introduction to Database Systems

Choosing a Data Model for Your Database

Transcription:

Introduction This document s purpose is to define Microsoft SQL server database design standards. The database being developed or changed should be depicted in an ERD (Entity Relationship Diagram). The Entity-relationship model for relational databases should be in third normal form. The model may be de-normalized where necessary for performance. The preferred naming convention is lowercase separated by underscores. If another convention (camel case, uppercase, etc.) is used, the database design should be consistent. A production database should only contain tables that are being used with the current applications. General Naming Conventions for Database Objects 1. Begin all names with a letter. 2. Only lowercase letters, 0-9 and _ (underscore) may be used. 3. Do not use SQL Server reserved words by themselves as names, e.g. database, join, primary, begin or between. Refer to corresponding version of SQL Server Books Online for a list of reserved words. 4. A column name should be unique within the table. 5. Names should be as short as possible while remaining meaningful. 6. Use underscores as delimiters. 7. Avoid prepositions where possible (e.g. use vessel_length rather than length_of_vessel). 8. Avoid meaningless or redundant names (e.g. data_tbl for a table name, col_1 for a column name). Database Objects Naming Standards Database objects include: I. Tables II. Column a. Standard Suffixes b. Audit Columns c. Primary Keys d. Foreign Keys III. Indexes IV. Views V. Triggers VI. Schemas VII. Security VIII. Roles I. Tables Table names should be short but meaningful. The maximum length is 128 characters for a table name. Use standard abbreviations (see EAD abbreviation Page 1 of 5 Revised September 18, 2009

list- VITADataAbbrevsV1) where possible and use underscores to separate the abbreviations (e.g. mfg_spec instead of manufacturing_specfication or mfgspec). Avoid generic meaningless table names like detail_data, tmp1 or table1. Table names must be unique throughout a database and describe their full significance within the organization. Table names should follow these rules: Table names should be singular Table names will use underscores between words Table names should not be longer than 128 characters Every table should have a primary or unique key Table names should not include embedded spaces II. Column Columns should honor the following guidelines: Column names must be unique within a table Columns names should not be longer than 128 characters Column names should be meaningful, use standard abbreviations, and use the correct data type Always use VARCHAR or NVARCHAR for text fields and specify a maximum length Numeric columns should use correct precision, e.g. NUMERIC(14,2) The column naming convention should be consistent. Column names should not include spaces a. Standard Suffixes It is useful to use a standard suffix to identify common types of fields. _cd _nbr _id _ind A code that is known and used by a user to identify an object (usually an alphanumeric code), e.g. mfg_cd. A number code that is known and managed by the user, e.g. part_nbr. A system generated unique number used internally within the database and not usually known by the user. This is usually generated by a sequence. For primary key columns, the column name will be <table name>_id; for foreign key columns, the column name will be <referenced table name>_id. A field used as an indicator field to indicate a specific subtype or role as identified during the analysis phase. Page 2 of 5 Revised September 18, 2009

b. Primary Key Numeric single-column primary key names should be <table name>_id, e.g. emp_id. This key should be the table name appended with id. The column should be auto generated. The column type should be INT or BIGINT. Every table should have a primary key that is auto generated c. Foreign Key The foreign keys should be defined to insure data integrity. Columns that are used to specify foreign keys in a table will normally have the same name as the key in the referenced table. If there is more than one foreign key relationship between two tables the differentiation between the foreign key columns should be represented by the definition of the column within the table. d. Audit Columns Audit columns should exist on every table unless the table is read-only. These columns are as follows: Logical Name Physical Name Data Type Nullable Create date cret_dttm DATETIME Not null Created by cret_by VARCHAR(30) Not null Update date updt_dttm DATETIME Not null Updated by Updt_by VARCHAR(30) Not null III. Indexes The DBA will need to find the best use of indexes. Indexes and relationships should be carefully created. Adjust the number of indexes to minimize performance issues. Limit the number of indexes on tables that will have significant insert and update activity. Increase the number of indexes on tables where it will improve performance. Consider if your usage would benefit from a clustered index. Covering indexes can be used, but be aware of the physical space required for the index. Page 3 of 5 Revised September 18, 2009

IV. Views Views can be used to hide the complexity of the underlying database structure, or customize the data for a set of users. Other uses for views include, controlling access to rows and columns of data and/or to aggregate data for performance. An indexed view can be used to enhance application performance. View names should reflect the purpose of the view and suffixed with _v View names will use underscores between abbreviations View names should not be longer than 128 characters Views should be limited in the number of columns they return V. Triggers Triggers typically have been used for auditing or DRI (Declarative Referential Integrity). With SQL server version 2008 auditing can be handled with the database. A best practice is to use primary and foreign keys for DRI instead of triggers. Triggers can be used to implement business rules Other uses of triggers are to performing validation or data modifications Suffix the trigger with _instrg for inserts, _updtrg for updates and _deltrg for deletes VI. Schemas A schema is a distinct namespace to facilitate the separation, management, and ownership of database objects. Use schemas to combine related, logical entities into one physical database to reduce administration overhead. The schema groups objects within one database into logical groups. Within Microsoft SQL 2005 & 2008, the database can not be backed up by schema. A database can not be restored by schema. VII. Security By default tables should not have PUBLIC access. Permissions on tables should be granted explicitly to users, roles and or schemas in a way that grants as little access as possible while granting everything needed and attempting to limit the number of roles, users and schemas which need to be managed. Additional VITA database security standards can be found at: http://www.vita.virginia.gov/uploadedfiles/library/psgs/it_security_standar d_501_01.pdf Page 4 of 5 Revised September 18, 2009

VIII. Roles Application and database roles are used to grant security permissions to a database. To easily manage the permissions in your databases, SQL Server provides several roles which are security principals that group other principals. They are like groups in the Microsoft Windows operating system. Database-level roles are database-wide in their permissions scope. There are two types of database-level roles in SQL Server: fixed database roles that are predefined in the database and flexible database roles that you can create. An application role is a database principal that enables an application to run with its own, user-like permissions. You can use application roles to enable access to specific data to only those users who connect through a particular application. Page 5 of 5 Revised September 18, 2009