Designing and Implementing SQL Server Tables and Views
https://www.pluralsight.com/courses/sqlserver-tables-view-designing-implementing
by Gerald Britton
Course Overview
- Course Overview
Introducing Tables and Views
- Version Check
- Introduction
- Relational Database Foundations
- Azure Data Studio Demo
- Business Problem: Bob's Shoes
- Course Overview
Designing and Implementing Tables
- Introduction
- Creating Identifiers
- table names must start with a letter, underscore, @ or #
- it cannot be longer than 128 characters
- Using Naming Conventions and The Mice!
- Using Character Data Types
- char(n): Use it if most of your columns will have the same or mostly the same length or if the length is less than 3.
- Using Integer Types
- Using Decimal Types
- Using Date and Time Types
- Demo 1: Creating the Order Tracking Table
- Using schemas for user tables is a good practice.
- they're great for managing security and granting and restricting access.
- you can force a computed column to be persisted by using the PERSISTED keyword when defining the column
- Using Collations
- All character data has some collation
- collation is used for sorting rules, case, and accent sensitivity
- Demo 2: Using Collations
- shows query to get collation for the server, the database, for each field of a table
- show how to set collation for a column
- Summary
Improving Table Design Through Normalization
- Introduction
- Identifying Problems with Unnormalized Data
- Setting Objectives for Normalization
- Demo 1 - Discovering Anomalies with Unnormalized Data
- Understanding First Normal Form
- Demo 2 - Transforming the Design to INF
- Understanding Second Normal Form
- Demo 3 - Transforming the Design to 2NF
- Understanding Third Normal Form
- Demo 3 - Transforming the Design to 3NF
- Considering Other Normal Forms
- Summary
Ensuring Data Integrity with Constraints
- Introduction and Overview
- Using NULL and DEFAULT Constraints
- Demo I - NULL and DEFAULT Constraints
- you cannot alter a constraint, you have to drop and recreate it
- Implementing the PRIMARY KEY Constraint
- SQL Server implements the PRIMARY KEY constraint with a backing index
- There can be only one clustered index per table,
- If a table has no clustered index, it is called a heap.
- Using Index Types and the UNIQUE Constraint
- unique constrains allow for NUlls but there can only be one null
- Demo 2 - Implementing PRIMARY KEY and UNIQUE Constraints
- More About Foreign Key Constraints
- Demo 3 - Using FOREIGN KEY Constraints
- shows example of UPDATE SET NULL
- creating a backing index for a foreign key is recommended
- Introducing CHECK Constraints
- Demo 4 - Using CHECK Constraints
- shows various example of using check constraint
- table constraint where you don't want two columns to have the same value
- check for specific values; CHECK (cust IN ('US','CA'))
- you can use a scalar function that returns a Boolean with a check constraint
- Options for Defining CHECK Constraints
- Summary
Designing View to Meet Business Requirements
- Introducing Views
- Overview and Motivation
- Reviewing the Bobs Shoes Order System Design
- Demo 1 - Creating a View to Produced a List of Customers
- Demo 2 - Using WITH SCHEMABINDING
- WITH SCHEMABINDING
- Base tables cannot be changed
- you must use two part name (dbo....)
- All referenced objects must be in the same database
- Working with Updateable Views
- Any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one base table.
- Demo 3 - Updating Tables using Views
- Summary
Implementing Indexed Views
- Introducing Indexed Views
- An indexed view is a persisted object stored in the database in the same way that table indexes are stored
- there must always be a clustered index on a indexed view
- Requirements for Indexed Views
- a view must be deterministic
- Demo I - Determining Determinism
- Query to show if columns are deterministic and precise
- YMIVR - Yet More Indexed View Requirements
- Forbidden T-SQL Elements
- COUNT, ROWSETs, OUTER JOINS
- Derived tables, self-joins, sub queries
- DISTINCT, TOP, ORDER BY
- UNION, EXCEPT, INTERSECT
- MIN, MAX, PIVOT, UNPIVOT
- Demo 2 - Indexing the Customer List View
- if you use EXPAND VIEWS, it tells SQL Server to ignore any indexes created for that view
- Demo 3 - Adding a Nonclustered Index and Views with Aggregates
- If GROUP BY is present, the VIEW definition must contain COUNT_BIG(*)
- Summary
Implementing Partitioned Views
- Introducing Partitioned Views
- Outlining a Partitioned View
- Reviewing the Requirements and Restrictions
- Demo 1 - Building a Partitioned View for the Orders Table
- Designing and Updating Partitioned Views
- Summary
Summary
- Wrapping Up
- Designing Tables
- Sqlserver Tables View Designing Implementing
- Considering Other Table Types
- Looking at Other Data Types
- Finishing Strong!
Comments
Post a Comment