Karen's Favourite Features of SQL Server 2016

61
Karen’s Favourite* Features of SQL Server 2016 …from a database designer’s Point of view Karen Lopez, InfoAdvisors

Transcript of Karen's Favourite Features of SQL Server 2016

Page 1: Karen's Favourite Features of  SQL Server 2016

Karen’s Favourite* Features of SQL Server 2016

…from a database designer’s Point of viewKaren Lopez, InfoAdvisors

Page 2: Karen's Favourite Features of  SQL Server 2016

I Am so HAPPY you are here!

Page 3: Karen's Favourite Features of  SQL Server 2016

Karen LopezKaren has 20+ years of data and information architecture experience on large, multi-project programs.She is a frequent speaker on data modeling, data-driven methodologies and pattern data models.She wants you to love your data.

Page 4: Karen's Favourite Features of  SQL Server 2016

A Little About InfoAdvisors…

#TeamData

Data ManagementProject ManagementBusiness AnalysisTrainingAnalysts ServicesConsulting

www.datamodel.com

Page 5: Karen's Favourite Features of  SQL Server 2016

“Every design decision comes down to cost,

benefit and risk.”

- Karen Lopez

Page 6: Karen's Favourite Features of  SQL Server 2016

Prelaunch CountdownSome of these slides come from a deck co-developed for a precon on DB Design – with Thomas LaRock www.thomaslarock.com @sqlrockstar

Page 7: Karen's Favourite Features of  SQL Server 2016

Launch

Page 8: Karen's Favourite Features of  SQL Server 2016

What is a DBA?

Development DBADatabase EngineerDatabase DesignerOperational DBANoSQL DBA

Page 9: Karen's Favourite Features of  SQL Server 2016

Security

Page 10: Karen's Favourite Features of  SQL Server 2016

SQL 2005 gave us cell-level

encryption

SQL 2008 gave us

TDE

BitLocker et al

Nothing new until SQL 2016

Security

Page 11: Karen's Favourite Features of  SQL Server 2016

Security – SQL 2016

Cell levelTDEAlways EncryptedData Masking*Row Level Security*

New!

Page 12: Karen's Favourite Features of  SQL Server 2016

Security – Always Encrypted

Enabled at column level

Protects data at rest *AND* in memory

Uses Column Master Key (client) and Column Encryption Key (server)

Page 13: Karen's Favourite Features of  SQL Server 2016

Security – Always Encrypted

Always!

Page 14: Karen's Favourite Features of  SQL Server 2016

Always Encrypted

Page 15: Karen's Favourite Features of  SQL Server 2016

Security – Always Encrypted

Deterministic – good for static values; can be

indexed• MUST use *_BIN2

collation (Latin1_General_BIN2)

Randomized – better security;

cannot be indexed• Not allowed in

WHERE clause!

Page 16: Karen's Favourite Features of  SQL Server 2016

Security – Always Encrypted

text/ntext/imageXML/hierarchyid/geography/geometryalias types/user-defined data typesSQL_VARIANTrowversion (timestamp)System alias (SYSNAME)Computed columnsIdentity columns

Sparse column setsTemporal tablesTriggers (partial support)Full text searchReplicationCDCIn Memory OLTPStretch database

Page 17: Karen's Favourite Features of  SQL Server 2016

Security – Always Encrypted

Foreign keys must match encryption types

Client code needs to support AE (currently this means .NET 4.6)

Page 18: Karen's Favourite Features of  SQL Server 2016

Security – Always Encrypted

Wizard

Page 19: Karen's Favourite Features of  SQL Server 2016

Why would a DB Designer love it?

Always Encrypted, yeah.Allows designers to not only specify which columns need to be protected, but how.Built in to the engine, easier for Devs

Page 20: Karen's Favourite Features of  SQL Server 2016

Security – Dynamic Data Masking

CREATE TABLE Membership(MemberID int IDENTITY PRIMARY KEY,     FirstName varchar(100) MASKED WITH (FUNCTION = 'partial(1,"XXXXXXX",0)') NULL,

    LastName varchar(100) NOT NULL,     Phone# varchar(12) MASKED WITH (FUNCTION = 'default()') NULL,     Email varchar(100) MASKED WITH (FUNCTION = 'email()') NULL);

INSERT Membership (FirstName, LastName, Phone#, Email) VALUES ('Roberto', 'Tamburello', '555.123.4567', '[email protected]'), ('Janice', 'Galvin', '555.123.4568', '[email protected]'), ('Zheng', 'Mu', '555.123.4569', '[email protected]');

Page 21: Karen's Favourite Features of  SQL Server 2016

Security – Dynamic Data Masking

Done at column level (NOT ENCRYPTION!)

Meant to complement other methods

Performed at the end of a database query right before data returnedPerformance impact small

Page 22: Karen's Favourite Features of  SQL Server 2016

Security – Dynamic Data Masking

4 function

s available

• Default• Email• Custom String• Random

Page 23: Karen's Favourite Features of  SQL Server 2016

Security – Dynamic Data Masking

Data in database is not changed

Ad-hoc queries *can* expose data

Does not aim to prevent users from exposing pieces of sensitive data

Page 24: Karen's Favourite Features of  SQL Server 2016

Security – Dynamic Data Masking

Cannot mask an encrypted column (AE)

Cannot be configured on computed column

But if computed column depends on a mask, then mask is returnedUsing SELECT INTO or INSERT INTO results in masked data being inserted into target (also for import/export)

Page 25: Karen's Favourite Features of  SQL Server 2016

Security – Dynamic Data Masking

Page 26: Karen's Favourite Features of  SQL Server 2016

Why would a DB Designer love it?

Allows central, reusable design for standard maskingOffers more reliable masking and more usable maskingRemoves whining about “we can do that later”

Page 27: Karen's Favourite Features of  SQL Server 2016

Security – Row Level Security

Filtering result sets (predicate based access)

Predicates applied when reading data

Can be used to block write access

User defined policies tied to inline table functions

Page 28: Karen's Favourite Features of  SQL Server 2016

Security – Row Level Security

No indication that results have been filteredIf all rows are filtered than NULL set returnedFor block predicates, an error returnedWorks even if you are dbo or db_owner role

Page 29: Karen's Favourite Features of  SQL Server 2016

Security – Row Level Security

Recommended to create schema for RLS objects (predicate functions and security policies)Use ALTER ANY SECURITY POLICY permissions; this does not require SELECT on the columnsAvoid type conversions in predicate functions to avoid runtime errors

Page 30: Karen's Favourite Features of  SQL Server 2016

Security – Row Level Security

Not Allowed

• DBCC SHOW_STATISTICS• FILESTREAM• Polybase • Indexed views• CDC nor change tracking

Page 31: Karen's Favourite Features of  SQL Server 2016

Security – Row Level Security

Page 32: Karen's Favourite Features of  SQL Server 2016

Why would a DB Designer love it?

Allows a designer to do this sort of data protection IN THE DATABASE, not just rely on code. Many, many pieces of code.

Page 33: Karen's Favourite Features of  SQL Server 2016

Security - Summary

Key differences TDE AE DDM RLS

Encryption Y Y N N

Protect data in memory N Y N N

Overhead Low* High Low Low

Block updates N N N Y

Page 34: Karen's Favourite Features of  SQL Server 2016

Security - Summary

Data quality?

Data availability?

Data recovery?

Query performance?

Legal requirements?

Which one is right for you?

Page 35: Karen's Favourite Features of  SQL Server 2016
Page 36: Karen's Favourite Features of  SQL Server 2016

Advanced Features and Updates

Love them all…

Page 37: Karen's Favourite Features of  SQL Server 2016

MOAR Foreign Keys!

What was the previous limit?

25310,000What is the new limit?

Page 38: Karen's Favourite Features of  SQL Server 2016

Why would a DB Designer love it?

…not so sure ….

Page 39: Karen's Favourite Features of  SQL Server 2016

Columnstore Improvements

Filter on NCI ColumstoreUpdateableIn-memory tables can useTable with Clustered Index Columnstore can have NCIPKs and FKs constraintsEven more performance improvements

Page 40: Karen's Favourite Features of  SQL Server 2016

Why would a DB Designer love it?

FasterMore optionsBetter

Page 41: Karen's Favourite Features of  SQL Server 2016

Advanced Features – Temporal Tables

ANSI SQL 2011 basedCurrent dataAccess to historical data Point-in-time analysisUses “period columns”

 System-Versioned Temporal Tables

Page 42: Karen's Favourite Features of  SQL Server 2016
Page 43: Karen's Favourite Features of  SQL Server 2016

System Versioned Table: Temporal Table

Page 44: Karen's Favourite Features of  SQL Server 2016

System Versioned Table: Temporal Table

Page 45: Karen's Favourite Features of  SQL Server 2016

Why would a DB Designer love it?

Don’t have hand-develop a solutionSQL Server knows what these tables are and can optimize itself when it uses them.

Page 46: Karen's Favourite Features of  SQL Server 2016

Advance Features: JSON

Not a data type in SQL Server 2016Results as JSON

Import JSON

Store JSON nvarchar()

Requires Compatibility Level 130

FOR JSONOPENJSON

Page 47: Karen's Favourite Features of  SQL Server 2016

Why JSON?

It’s Hipster!Common for data exchangeCommon for persistence

Tools

Preferred

Page 48: Karen's Favourite Features of  SQL Server 2016

Getting JSON out…

Page 49: Karen's Favourite Features of  SQL Server 2016

SSMS

Page 50: Karen's Favourite Features of  SQL Server 2016

JSON – Getting it in

Page 51: Karen's Favourite Features of  SQL Server 2016

Why would a DB Designer love it?

Don’t have hand-develop a solutionYour Devs will Love you MoreYou can be faster and better because you now speak a new language

Page 52: Karen's Favourite Features of  SQL Server 2016

Physical Files – Stretch Database

Stretch Database• Migrate least used data to Azure• Migrate some or entire table if desired• Stretch database ensures no data is

lost• DMVs provided to show progress

Page 53: Karen's Favourite Features of  SQL Server 2016

Physical Files – Stretch Database

Stretch Database• You can pause migration• No change to queries• Latency expected for querying

historical data

Page 54: Karen's Favourite Features of  SQL Server 2016

Physical Files – Stretch Database

Page 55: Karen's Favourite Features of  SQL Server 2016

Stretch Database

Enable Remote Data ArchiveHot & Cold dataOn-Prem & Cloud

EXEC sp_configure 'remote data archive' , '1'; GO RECONFIGURE; GO

Page 56: Karen's Favourite Features of  SQL Server 2016

Why Stretch?

Smaller backupsApplication ignorantPerformance on hot dataPerformance* on cold data

Page 57: Karen's Favourite Features of  SQL Server 2016

Why not Stretch?

UniquenessCertain datatypes ReplicationView limitationsIndex limitationsMore…

Uniqueness is not enforced for UNIQUE constraints and PRIMARY KEY constraints on a Stretch-enabled table.

Page 58: Karen's Favourite Features of  SQL Server 2016

Why would a DB Designer love it?

Don’t have hand-develop a solutionIt’s all automaticYour devs will love you because no app changes required.

Page 59: Karen's Favourite Features of  SQL Server 2016

Finally…

Many, many performance enhancements. It’s just FASTER. No design changes needed.

Page 60: Karen's Favourite Features of  SQL Server 2016

One more time… Every Design Decision must be based on Cost, Benefit

and Risk

Page 61: Karen's Favourite Features of  SQL Server 2016

Thank you!

I’d appreciate feedback of any type about this presentation.

[email protected]