Categories
SQL

Data Integrity Foundations with Constraints (Part 2)

Last week we started to at the use of constraints to support with data integrity in our databases. As a refresher on our introduction from last time: Data integrity helps give us assurance that our data is accurate, complete, and free from errors or inconsistencies. Some of this comes from making sure that data is correct […]

Categories
SQL

Data Integrity Foundations with Constraints (Part 1)

Data integrity helps give us assurance that our data is accurate, complete, and free from errors or inconsistencies. Some of this comes from making sure that data is correct before it enters are databases, but there are some tools we have in our databases which can help with this too – Constraints! Before we jump […]

Categories
SQL Server

Modifying Data in Multi Table Views

Last time out we looked at modifying data in a view, but this only worked when we had a view referencing a single table. Here we’ll look at how we can achieve the same result for a view which references multiple tables. This one will require a little more work for us in the form of some extra […]

Categories
SQL Server

Modifying Data in a View

A view can be created in SQL Server to allow data to be presented in a specific way for a particular user or use case which may need to consume it. Recently I came upon a feature which I hadn’t been aware of throughout my career around SQL Server – you can perform data modifications […]

Categories
SQL Server

Auditing Schema Changes with DDL Triggers

A couple of weeks back we looked at how to implement DDL triggers in a database and briefly created a couple as examples. This time we’ll put that into use with a particular purpose: to audit modifications to our database schema. Storing the audit Before we get to the trigger we want to create a table to […]

Categories
SQL Server

Implementing DML Triggers

Last time out we looked at implementing DDL triggers in SQL Server and today we’re going to look at the other commonly used trigger – DML. What are DML triggers DML triggers are used to react to events caused by data manipulation language (DML) statements. These events are targeted to a specific table or view and so […]

Categories
SQL Server

Implementing DDL Triggers

In SQL Server we have the ability to create triggers to respond to events occurring within our databases or across the server. These typically come in two varieties – DDL and DML triggers. Here we’ll look at what DDL triggers are and how to implement them. What are DDL triggers A DDL trigger is a […]

Categories
SQL

Naming Scope in SQL Server

When creating items in SQL Server we aren’t able to create multiple with the same name, for example two tables named dbo.Sales. Similarly we couldn’t create a table and view with the same name. However it isn’t the case that everything we create within a database has to be named uniquely. It can depend on […]

Categories
SQL

Performance Enhancements for Vertical Partitioning

We’ve previously looked at how to implement vertical partitioning and the benefits it can bring within our data. Here I’d like to dive a little further into improving the performance even further with a couple of modifications to our schema. We’ll use the same setup as we had previously to create the table, populate it and partition it. This results in […]

Categories
SQL

Benefits of Vertical Partitioning

We recently looked at implementing vertical partitioning on a set of data. In an earlier introduction post we also mentioned the benefits which can be seen as a result of the partitioning in both our maintenance and querying of the data. Here we’ll take a look at those benefits with a little more evidence. We’ll be using the data […]