Module 3 Designing a Physical Database Model. Module Overview Selecting Data Types Designing Database Tables Designing Data Integrity.

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
Module 12: Auditing SQL Server Environments
Module 2 Designing a Logical Database Model. Module Overview Guidelines for Building a Logical Database Model Planning for OLTP Activity Evaluating Logical.
Advantage Data Dictionary. agenda Creating and Managing Data Dictionaries –Tables, Indexes, Fields, and Triggers –Defining Referential Integrity –Defining.
Module 7 Designing Queries for Optimal Performance.
Module 4: Creating Data Types and Tables. Overview Creating Data Types Creating Tables Generating Column Values Generating Scripts.
Module 9 Designing an XML Strategy. Module 9: Designing an XML Strategy Designing XML Storage Designing a Data Conversion Strategy Designing an XML Query.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Chapter 9: Creating Database Conventions & Standards MCITP Administrator: Microsoft SQL Server 2005 Database Server Infrastructure Design Study Guide (70-443)
Module 17 Storing XML Data in SQL Server® 2008 R2.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
Overview SQL Server 2008 Overview Presented by Tarek Ghazali IT Technical Specialist Microsoft SQL Server MVP, MCTS Microsoft Web Development MCP ITIL.
Module 2 Creating Active Directory ® Domain Services User and Computer Objects.
Module 2 Working with Data Types. Module Overview Using Data Types Working with Character Data Converting Data Types Working with Specialized Data Types.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
Module 4: Data Objects. Overview Tables are the main objects that store data Indexes, views, stored programs and other objects are the support structures.
An Investigation of Oracle and SQL Server with respect to Integrity, and SQL Language standards Presented by: Paul Tarwireyi Supervisor: John Ebden Date:
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
Module 9 Configuring Messaging Policy and Compliance.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
Module 4 Designing Databases for Optimal Performance.
Module 9 Designing and Implementing Stored Procedures.
WHAT’S NEW IN SQL SERVER 2008: T-SQL Martin Bell SQL Server MVP.
Module 5 Planning for SQL Server® 2008 R2 Indexing.
10 Copyright © 2009, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
1 Copyright © 2006, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Module 9 Configuring Messaging Policy and Compliance.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
Unit 6 Data Storage Design. Key Concepts 1. Database overview 2. SQL review 3. Designing fields 4. Denormalization 5. File organization 6. Object-relational.
Module 16: Performing Ongoing Database Maintenance
Module 3: Creating Data Types and Tables. Overview Working with Data Types Working with Tables Generating Column Values Generating Scripts.
Module 4 Designing and Implementing Views. Module Overview Introduction to Views Creating and Managing Views Performance Considerations for Views.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Module 3 Designing and Implementing Tables. Module Overview Designing Tables Working with Schemas Creating and Altering Tables.
Data Types Lesson 4. Skills Matrix Table A table stores your data. Tables are relational in that they are organized as rows and columns (a matrix). Each.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
Module 4: Implementing Data Integrity
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Module 11 Authorizing Users to Access Resources. Module Overview Authorizing User Access to Objects Authorizing Users to Execute Code Configuring Permissions.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Sql DDL queries CS 260 Database Systems.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
Session 1 Module 1: Introduction to Data Integrity
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 14 Database Design.
SQL Server 2012 Session: 1 Session: 12 Triggers Data Management Using Microsoft SQL Server.
Module 10 Merging Data and Passing Tables. Module Overview Using the MERGE Statement Implementing Table Types Using Table Types As Parameters.
Module 9: Using Advanced Techniques. Considerations for Querying Data Working with Data Types Cursors and Set-Based Queries Dynamic SQL Maintaining Query.
SQL Triggers, Functions & Stored Procedures Programming Operations.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
SQL Basics Review Reviewing what we’ve learned so far…….
1 Agenda TMA02 M876 Block 4. 2 Model of database development data requirements conceptual data model logical schema schema and database establishing requirements.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Creating Database Objects
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Creating Database Triggers
Module 2: Creating Data Types and Tables
Module 5: Implementing Data Integrity by Using Constraints
STRUCTURED QUERY LANGUAGE
Microsoft SQL Server 2014 for Oracle DBAs Module 7
PT2520 Unit 5: Physical Design
Attributes and Domains
Chapter 2: Creating And Modifying Database Tables
Creating Database Objects
Responding to Data Manipulation Via Triggers
Presentation transcript:

Module 3 Designing a Physical Database Model

Module Overview Selecting Data Types Designing Database Tables Designing Data Integrity

Lesson 1: Selecting Data Types Considerations for Selecting Standard Column Data Types Considerations for Selecting New SQL Server 2008 Data Types Considerations for Using CLR User-Defined Data Types Considerations for Using Spatial Data Types Guidelines for Using the XML Data Type Establishing Naming Standards for Database Objects Discussion: Working with Data Tables

Considerations for Selecting Standard Column Data Types Integer versus GUID primary keys Fixed versus variable length columns VARCHAR (MAX), NVARCHAR (MAX), and VARBINARY (MAX) data types Character column collations and Unicode and non-Unicode data types Transact-SQL user-defined data types

Considerations for Selecting New SQL Server 2008 Data Types Same date precision as date Same time precision as time DateTimeOffset is time zone aware Same date precision as date Same time precision as time DateTimeOffset is time zone aware Datetime2 / Datetimeoffset When a table contains a FILESTREAM column When objects are larger than 1 MB Where fast read access is important Where you use a middle tier When a table contains a FILESTREAM column When objects are larger than 1 MB Where fast read access is important Where you use a middle tier FILESTREAM Date: From 01/01/0001 to 12/31/9999 Date: No time component Time: Based on 24 hour clock, NO date component Time: Accurate to 100 ns Date: From 01/01/0001 to 12/31/9999 Date: No time component Time: Based on 24 hour clock, NO date component Time: Accurate to 100 ns Date / Time To create tables with a hierarchical structure To query and perform work with hierarchical data by using T-SQL To create tables with a hierarchical structure To query and perform work with hierarchical data by using T-SQL Hierarchyid

Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.

Considerations for Using CLR User-Defined Data Types Use common language runtime (CLR) user-defined data types for nonstandard or proprietary data types Avoid excessively complex data types Consider the risks of tightly coupling a CLR user-defined data types and the database Consider the overhead of row-by-row processing

Considerations for Using Spatial Data Types Spatial Data: Represents information on the location and shape of geometric objects Can be of two types including geometry and geography data types Implemented as.NET common language runtime data types in SQL Server Supports eleven spatial data objects, or instance types Represents information on the location and shape of geometric objects Can be of two types including geometry and geography data types Implemented as.NET common language runtime data types in SQL Server Supports eleven spatial data objects, or instance types Spatial Data Geometry Data Type Geography Data Type

Guidelines for Using the XML Data Type Use the XML data type for data that is not frequently updated Use typed XML columns Use the XML data type for data that is not relationally structured Use the XML data type for configuration information Use the XML data type for data with recursive structures

Establishing Naming Standards for Database Objects Use only standard abbreviations in names Use names that comply with the rules for forming SQL Server 2008 identifiers Use descriptive terms Use models for naming standards Be consistent across all objects Record and communicate naming standards Use prefixes ONLY when it provides value Use policy-based management Name intersection tables consistently

Discussion: Working with Data Tables Scenario: Some developers argue to use a simple table structure containing only four columns—a unique row identifier, a field identifier (analogous to a column name), a datatype indicator, and the data itself stored as a sqlvariant. Some say that the application could reconstitute all data fields, and pivot them into a virtual table. The argument often goes further to whether developers should be involved in working with the database schema, since they can create new data properties (fields) as needed. Question: What is the fallacy in these arguments?

Guidelines for Determining Table Width What Are Sparse Columns? Demonstration: How To Create a Table By Using Sparse Columns Guidelines for Using Computed Columns Discussion: Using Computed Columns Lesson 2: Designing Database Tables

Guidelines for Determining Table Width Large Object Types Data Overflow Capacity Planning

Properties of Sparse Columns What Are Sparse Columns? The SQL Server Database Engine uses the SPARSE keyword in a column definition to optimize the storage of values in that column. Catalog views for a table that has sparse columns are the same as for a typical table. The COLUMNS_UPDATED function returns a varbinary value to indicate all the columns that were updated during a DML action. The SQL Server Database Engine uses the SPARSE keyword in a column definition to optimize the storage of values in that column. Catalog views for a table that has sparse columns are the same as for a typical table. The COLUMNS_UPDATED function returns a varbinary value to indicate all the columns that were updated during a DML action. Sparse columns are ordinary columns that have an optimized storage for NULL values. They can be used with column sets and filtered index. Data types that you cannot specify as sparse are geography, geometry, image, ntext, text, timestamp, and user-defined data types.

Demonstration: How To Create a Table By Using Sparse Columns In this demonstration, you will see how to: Create a table by using sparse columns

Avoid the overhead of complex functions in computed columns Avoid persisted computed columns on active data Protect against numeric overflow and divide by zero errors Use persisted computed columns for performance Guidelines for Using Computed Columns Use computed columns to derive results from other columns Usage of Computed Columns Exceptions in Column Data Usage of Persisted Computed Columns Usage of Computed Columns Exceptions in Column Data Computed Columns

Discussion: Using Computed Columns What kind of problems do computed columns solve? When is a computed column actually computed?

Lesson 3: Designing Data Integrity Guidelines for Designing Column Constraints Guidelines for Designing Table Constraints Guidelines When Implementing DDL Triggers Discussion: Identifying the Best Options for Column Data Types and Data Constraints

Guidelines for Designing Column Constraints Use column CHECK Constraints CONSTRAINT chkQty CHECK (Amount > 0)...) Declare columns as NOT NULL (HireDate int NOT NULL...) Use ANSI default constraints (CONSTRAINT Qty DEFAULT 0...) Use CHECK constraints instead of bound rules Check Constraint Bound Rules

Guidelines for Designing Table Constraints Use DRI for data integrity in a database Use triggers to enforce referential integrity Use ANSI-standard options Use table-level CHECK constraints Check Constraint ON DELETE Specify cascading levels and options

Guidelines for Designing Database Constraints by Using DDL Triggers Use DDL triggers for auditing Use DDL triggers to prevent database changes Use DDL triggers to support security

Guidelines When Implementing DDL Triggers Use DDL triggers with transactions Use DDL triggers scope to control database operations or objects that activates the trigger Avoid creating DDL Trigger on both CREATE_SCHEMA and CREATE_TABLE event Use value() instead of query() when querying data returned from EVENTDATA

Discussion: Identifying the Best Options for Column Data Types and Data Constraints Scenario: QuantamCorp is a local company conducting business only in USA and Canada. You need to create a single table to contain the following information. 1. Time of the day for a 24 hour clock 2. Company name 3. address 4. Postal code 5. Product information 6. Product descriptive brochure 7. Telephone number Question: What are the best options for column data types and data constraints?

Lab 3: Designing a Physical Database Model Exercise 1: Specifying Database Object Naming Standards Exercise 2: Converting a Logical Database Model into a Physical Database Model Estimated time: 40 minutes Logon Information Virtual machine User name Password NYC-SQL1 Administrator Pa$$w0rd

Lab Scenario The main goals of the HR VASE project are as follows: Provide managers with current and historical information about employee vacation and sick-leave data. Provide permission to individual employees to view their vacation and sick-leave balances. Provide permission to selected employees in the HR department to view and update employee vacation and sick-leave data. Provide permission to the HR manager to view and update all the data. Standardize employee job titles. In this lab, you will build a physical database model based on the logical model created earlier. You are a lead database designer at QuantamCorp. You are working on the Human Resources Vacation and Sick Leave Enhancement (HR VASE) project that is designed to enhance the current HR system of your organization. This system is based on the QuantamCorp2008 sample database in SQL Server 2008.

Lab Review Can you explain the purpose of creating naming standards and having a Naming Standards policy? What kind of issues may arise if a Naming Standards policy does not exist?

Module Review and Takeaways Review Questions Real-world Issues and Scenarios

Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.