Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
SQL Server 2014 Development Essentials
SQL Server 2014 Development Essentials

SQL Server 2014 Development Essentials: Design, implement, and deliver a successful database solution with Microsoft SQL Server 2014.

Arrow left icon
Profile Icon A. Masood-Al-Farooq
Arrow right icon
€8.99 €28.99
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3 (3 Ratings)
eBook Jul 2014 214 pages 1st Edition
eBook
€8.99 €28.99
Paperback
€35.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon A. Masood-Al-Farooq
Arrow right icon
€8.99 €28.99
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3 (3 Ratings)
eBook Jul 2014 214 pages 1st Edition
eBook
€8.99 €28.99
Paperback
€35.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €28.99
Paperback
€35.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

SQL Server 2014 Development Essentials

Chapter 2. Understanding DDL and DCL Statements in SQL Server

Once you have completed the physical design phase of the database design process, the next step is to implement your proposed database solution.

The Structured Query Language (SQL) of Microsoft SQL Server is called Transact-SQL (T-SQL). The Transact-SQL statements have three categories: Data Definition Language (DDL) statements, Data Control Language (DCL) statements, and Data Manipulation Language (DML) statements that can be used to create, modify, and query SQL Server databases and tables.

In this chapter, we'll be covering the following topics:

  • Understanding DDL, DCL, and DML language elements
  • Understanding the purpose of SQL Server 2014 system databases
  • Exploring database recovery models
  • Creating and modifying databases
  • Creating and modifying database schemas
  • Creating and modifying tables
  • Grating, revoking, and denying permissions to securables

Understanding the DDL, DCL, and DML language elements

As mentioned earlier, the Transact-SQL statements have three categories: DDL statements, DCL statements, and DML statements. Each of the commands in these categories include keywords and parameters that can be used to create, modify, and query SQL Server 2014 databases and tables. Let's have a quick look at the keywords and the purpose of each T-SQL statement type in the following sections.

Data Definition Language (DDL) statements

The T-SQL DDL statements include keywords that you can use to create databases and database objects, modify databases and database objects, and remove databases and database objects. The DDL statements consist of the following keywords: CREATE, ALTER, and DROP. Using these DDL keywords, you can create and modify the structure of your databases and create and modify all kinds of database objects (tables, schemas, indexes, stored procedures, functions, views, triggers, login accounts, database users, server...

Understanding the purpose of SQL Server 2014 system databases

Before you start creating databases on a SQL Server 2014 instance, you should have a good understanding of the system databases that are installed by default when a SQL Server 2014 instance is created. Each SQL Server 2014 system database has a specific purpose and is required to run SQL Server. So, having a good understanding of the SQL Server system databases is useful when you are troubleshooting SQL Server issues.

SQL Server 2014 system databases

By default, when you install a SQL Server 2014 instance, the SQL Server 2014 setup program creates the following five system databases: master, model, msdb, tempdb, and resource. Apart from these system databases, there is another system database called distribution that does not exist until you configure replication on the SQL Server instance.

The master database

The master database, as its name implies, is the most important database in a SQL Server 2014 instance. In fact, it is the...

An overview of database recovery models

The recovery model determines how the transactions are logged, whether the backups of transaction logs are allowed, and the type of restore options available to recover the database. The SQL Server 2014 database can be configured to one of three recovery models, which are explained in the following sections.

The simple recovery model

When you use the simple recovery model, SQL Server logs a minimal amount of transactions in the transaction log file, and the transaction log is truncated as soon as transactions are committed. Simple recovery does not allow backups of transaction log files; therefore, databases with a simple recovery model are vulnerable to data loss because you cannot restore the databases to a specific point in time.

The bulk-logged recovery model

With the bulk-logged recovery model, bulk operations are minimally logged in the transaction log file, reducing the overall size of the transaction log file. All other operations are fully logged...

Creating and modifying databases

You can use either Transact-SQL DDL statements or SQL Server Management Studio to create and modify databases. In the following subsections, we will discuss these options.

Create, modify, and drop databases with T-SQL DDL statements

In this section, we will cover Transact-SQL DDL statements that are used to create, alter and modify SQL Server databases.

Creating a database with T-SQL DDL statements

We use the CREATE DATABASE statement to create a new database on SQL Server. The general syntax for the CREATE DATABASE command is as follows:

CREATE DATABASE database_name
[CONTAINMENT = {NONE | PARTIAL}]
[ON [PRIMARY] [<filespec> [,...n]
[,<filegroup> [,...n]]
[LOG ON <filespec> [,...n]]]
[COLLATE collation_name]
[WITH <option> [,...n]]
[;]

The following are the arguments of the CREATE DATABASE command:

  • database_name: This is the name of new SQL Server database. The database name must be unique with an instance of SQL Server.
  • CONTAINMENT: This...

Creating and managing database schemas

A schema is a logical container that groups objects of similar scope or ownership together. By default, the database owner (dbo) schema is automatically created in a SQL Server database. Unless you specify otherwise, all SQL Server user objects are created in the database owner (dbo) schema. You can define different default schemas for each user of the database. When you create a user database, SQL Server automatically creates these schemas: sys, dbo, INFORMATION_SCHEMA, and guest.

You can query the sys.schemas system catalog view to see the schemas defined for the database. The following is the syntax to query this system catalog:

SELECT * FROM sys.schemas

You can also use SQL Server Management Studio 2014 to list the schemas defined for the database. To list the schemas defined for the database in SQL Server 2014 Management Studio, use the following steps:

  1. In Object Explorer, expand the Databases folder.
  2. Next, select the database and expand the Security...

Understanding the DDL, DCL, and DML language elements


As mentioned earlier, the Transact-SQL statements have three categories: DDL statements, DCL statements, and DML statements. Each of the commands in these categories include keywords and parameters that can be used to create, modify, and query SQL Server 2014 databases and tables. Let's have a quick look at the keywords and the purpose of each T-SQL statement type in the following sections.

Data Definition Language (DDL) statements

The T-SQL DDL statements include keywords that you can use to create databases and database objects, modify databases and database objects, and remove databases and database objects. The DDL statements consist of the following keywords: CREATE, ALTER, and DROP. Using these DDL keywords, you can create and modify the structure of your databases and create and modify all kinds of database objects (tables, schemas, indexes, stored procedures, functions, views, triggers, login accounts, database users, server and...

Understanding the purpose of SQL Server 2014 system databases


Before you start creating databases on a SQL Server 2014 instance, you should have a good understanding of the system databases that are installed by default when a SQL Server 2014 instance is created. Each SQL Server 2014 system database has a specific purpose and is required to run SQL Server. So, having a good understanding of the SQL Server system databases is useful when you are troubleshooting SQL Server issues.

SQL Server 2014 system databases

By default, when you install a SQL Server 2014 instance, the SQL Server 2014 setup program creates the following five system databases: master, model, msdb, tempdb, and resource. Apart from these system databases, there is another system database called distribution that does not exist until you configure replication on the SQL Server instance.

The master database

The master database, as its name implies, is the most important database in a SQL Server 2014 instance. In fact, it is the...

An overview of database recovery models


The recovery model determines how the transactions are logged, whether the backups of transaction logs are allowed, and the type of restore options available to recover the database. The SQL Server 2014 database can be configured to one of three recovery models, which are explained in the following sections.

The simple recovery model

When you use the simple recovery model, SQL Server logs a minimal amount of transactions in the transaction log file, and the transaction log is truncated as soon as transactions are committed. Simple recovery does not allow backups of transaction log files; therefore, databases with a simple recovery model are vulnerable to data loss because you cannot restore the databases to a specific point in time.

The bulk-logged recovery model

With the bulk-logged recovery model, bulk operations are minimally logged in the transaction log file, reducing the overall size of the transaction log file. All other operations are fully logged...

Left arrow icon Right arrow icon

Description

This book is an easy-to-follow, comprehensive guide that is full of hands-on examples, which you can follow to successfully design, build, and deploy mission-critical database applications with SQL Server 2014. If you are a database developer, architect, or administrator who wants to learn how to design, implement, and deliver a successful database solution with SQL Server 2014, then this book is for you. Existing users of Microsoft SQL Server will also benefit from this book as they will learn what's new in the latest version.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 25, 2014
Length: 214 pages
Edition : 1st
Language : English
ISBN-13 : 9781782172567
Vendor :
Microsoft
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jul 25, 2014
Length: 214 pages
Edition : 1st
Language : English
ISBN-13 : 9781782172567
Vendor :
Microsoft
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 100.97
SQL Server 2014 Development Essentials
€35.99
Microsoft SQL Server 2014 Business Intelligence Development Beginner's Guide
€41.99
Getting Started with SQL Server 2014 Administration
€22.99
Total 100.97 Stars icon
Banner background image

Table of Contents

7 Chapters
1. Microsoft SQL Server Database Design Principles Chevron down icon Chevron up icon
2. Understanding DDL and DCL Statements in SQL Server Chevron down icon Chevron up icon
3. Data Retrieval Using Transact-SQL Statements Chevron down icon Chevron up icon
4. Data Modification with SQL Server Transact-SQL Statements Chevron down icon Chevron up icon
5. Understanding Advanced Database Programming Objects and Error Handling Chevron down icon Chevron up icon
6. Performance Basics Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(3 Ratings)
5 star 0%
4 star 33.3%
3 star 33.3%
2 star 33.3%
1 star 0%
Qais Akhtar Apr 14, 2017
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
good
Amazon Verified review Amazon
Ian Stirk Sep 01, 2014
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Hi,I have written a detailed chapter-by-chapter review of this book on www DOT i-programmer DOT info, the first and last parts of this review are given here. For my review of all chapters, search i-programmer DOT info for STIRK together with the book's title.This short but wide-ranging book aims to cover the SQL Server 2014's development essentials, from the beginning, to in-depth knowledge, how does it fare?The book's introduction says "This book will provide you with all the skills you need to successfully design, build, and deploy databases using SQL Server 2014. Starting from the beginning, this book gives you an insight into the key stages of the SQL Server database process, provides you with an in-depth knowledge of the SQL Server database architecture, and shares tips to help you design the new database."Below is a chapter-by-chapter exploration of the topics covered.Chapter 1 Microsoft SQL Server Database Design PrinciplesThis chapter aims to cover the major steps in database design. It begins with a look at the place of database design within systems development, noting a poor design can lead to slow or unused systems.Database design is broken down, and described briefly in the following steps:*Requirements gathering/analysis (interviews, analysis, user and functional requirements)*Conceptual design (meets requirements, independent of database vendor, E-R diagrams)*Logical design (maps E-R diagram to database vendor)*Physical design (map to database structures)*Implementation/loading (create database and tables, load data, configure)*Testing/evaluation (performance, integrity, concurrency, security)Table design is considered next, tables contain columns and rows that store data. Business entities form the basis of tables, and the entity's attributes become table columns. The associations between the different tables are described using 1-to-1, 1-to-many, and many-to-many relationships.Data integrity ensures data is reliable and follows business rules. Integrity is examined briefly in terms of domain (e.g. check constraint), entity (e.g. primary key), referential (e.g. foreign key), and user-defined (e.g. triggers). Normalization is discussed as a means of reducing data redundancy, so the data exists only once. The first 3 normal forms are described briefly.An overview of SQL Server's file architecture is given, consisting of a primary data file, zero or more secondary data files, and a log file. The structure of a database page (i.e. header, data rows, offset array) is described, as are extents (8 contiguous pages), the transaction log (allow rollback/recovery), and filegroups (allow easier admin). Finally, the importance of data types is described.This chapter provides a whirlwind review of the major steps and considerations in creating a database. While it is wide-ranging, it often lacks depth. Several features are mentioned in passing (e.g. checkpoint), without any explanation being given.The database design section mentions using data flow diagrams (DFDs), instead some of the various more `modern' UML diagrams should have been mentioned. The definitions of the normal forms feel awkward, and composite keys are referenced in second normal form - without first describing what a composite key is. Deriving the business entities from the user/functional requirements is not discussed.The chapter does provide a good review of the major steps in database design (especially if you already know the subject matter), which for the most part is independent of SQL Server itself. There are some useful links for further information. There's a useful diagram that describes the working of the transaction log....ConclusionThis book contains SQL syntax and typically brief example code covering a wide-range of SQL Server development topics. Although it is wide-ranging, it lacks depth, even for an `essentials' book.If you are new to SQL Server, which is the intended market, this book will give you a basic understanding of using SQL Server from a developer's perspective, taking you from say level 0 to level 3 or 4 (out of 10). It does not contain enough detail to be a useful teaching aid. If you already understand the subject matter, this book can be used as a refresher, with the proviso it has limited depth.Little of the book relates specifically to SQL Server 2014. About 95% of the book is equally applicable to SQL Server 2012. which is not surprising since the major changes in SQL Server 2014 from a developer's perspective tend to be internal. You can see the changes here: http://msdn.microsoft.com/en-us/library/bb510411.aspx. I suspect the 2014 in the title is to catch the market for new SQL Server 2014 books.In many ways, the book contains the right topics and subheadings, but to be more useful, the content should have been expanded to include more detail, examples, tips, troubleshooting remarks, and explained output/results.
Amazon Verified review Amazon
A. Zubarev Aug 31, 2014
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I read it in one large gulp as the book is not lengthy at 170 + or so actually useful pages. The material is written in concise, clear manner. Besides, I expected least at as many more pages for such a complex and feature rich product.But what did the book promise? The primary goal is to have a reader developed enough skills to deliver a successful database application.The book targets database developers, administrators and architects.However, the book deserves a lot of criticism, for example the many-to-many relationship in the book is represented in form of two tables, unfortunately, the true many-to-many relationship in RDBMS` cannot be achieved without an interim, third table, this will make many folks upset so I have submitted errata, but I can’t understand how Packt makes it shared for all readers. I shall continue on this note and also tell that even a greater flaw in this book exists – overall,s i it not providing enough guidance, advice or reference. I mean if a topic say on locking is covered why the author would not advocate on which locking option to use under what circumstances? The same applies to most topics. Furthermore, I was surprised almost nothing was covered about a database operating in the Cloud (Azure), CLR functions, CDC, no mention on Service Broker, Master Data Management, Data Quality, etc. the same is true to many more canned features (just too many to mention); without the aforesaid this book is of much less help to software architects and incomplete from for developers. The not so advocated to be used SQL Profiler is covered beside the Dynamic Management Views whereas I expect the database tuning and troubleshooting become a separate chapter on its own.In short, I am disappointed this time, I just fail to see what gap this book closes and simply how it is any better than just reading on product features on Microsoft’s site, then more in-depth in BOL, MSDN and blog posts of the most prominent SQL Server industry leaders.Two stars out of five because it may be served as a guide or read as preamble to starting developing a new SQL Server based database.Disclaimer: this book was given to me for free by Packt Publishing in exchange to publishing a timely review.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.