Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learn SQL Database Programming
Learn SQL Database Programming

Learn SQL Database Programming: Query and manipulate databases from popular relational database servers using SQL

By Josephine Bush
$29.99 $20.98
Book May 2020 564 pages 1st Edition
eBook
$29.99 $20.98
Print
$43.99
Subscription
$15.99 Monthly
eBook
$29.99 $20.98
Print
$43.99
Subscription
$15.99 Monthly

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
Buy Now

Product Details


Publication date : May 29, 2020
Length 564 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781838984762
Category :
Table of content icon View table of contents Preview book icon Preview Book

Learn SQL Database Programming

Introduction to Relational Database Management Systems

This chapter introduces the concepts required to understand the basics of relational database management systems (RDMS). It will introduce foundational topics such as SQL, the relational model, data integrity, database normalization, and the types of relational database management systems. It will provide you with fundamental knowledge about SQL and databases that will be required throughout this book.

In this chapter, we will cover the following topics:

  • Understanding SQL
  • Understanding databases
  • Understanding data integrity
  • Understanding database normalization
  • Types of RDMS

Understanding SQL

Structured Query Language, or SQL (pronounced see-quel), is the language that is used for querying and manipulating data and defining structures in databases. Initially developed at IBM in the early 1970s, SQL became an ANSI and ISO standard in 1986.

SQL is a powerful, yet simple language, and can do many things, such as execute queries, retrieve, insert, update, and delete data, create databases and tables, and much more.

These types of activities can be grouped into different subdivisions of SQL: Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL):

  • Use DDL commands to specify database schema:
  • CREATE: This is used to create a new database or objects in a database.
  • ALTER: This is used to alter a database or objects in a database.
  • DROP: This is used to delete a database or objects in a database.
  • TRUNCATE: This is...

Understanding databases

A database is a collection of data. You store databases in a relational database management system (RDMS). The RDMS is the basis for modern database systems like MySQL, SQL Server, Oracle, PostgreSQL, and others. These will be covered in more detail later in this chapter.

Tables

In an RDMS, objects called tables store data. Tables are a collection of related data stored in columns and rows. The following screenshot is a cross-section of a table that contains data about baseball players' appearances in all-star games:

A NULL value in a table is a value that appears to be blank. It doesn't represent a string of blank spaces, zero, or a zero-length character string: it's a missing or unknown...

Understanding data integrity

Data integrity refers to the consistency and accuracy of the data. It is typically enforced by the procedures and guidelines in the database design phase. In RDMS, keys enforce data integrity. A key is user-defined and forces values in a table to conform to a specified standard. This standard will allow only certain kinds of values to be in the database.

Types of integrity

Data integrity refers to the consistency and accuracy of data and table relationships. The following table lists the types of integrity you can use:

Entity integrity

Referential integrity

Domain integrity

Unique constraint

Foreign key

Check constraint

Not null constraint

Default constraint

Primary key...

Database normalization

Database normalization is the process of putting your raw data into tables using rules to avoid redundant data, optimize database performance, and ensure data integrity.

Without proper normalization, not only can you have data redundancy, which uses additional storage space, but it can be more difficult to update and maintain the database without data loss.

Normalization requires forms. Forms are sets of rules to follow to normalize your data into database tables. There are three forms that we will discuss: the first normal form, the second normal form, and the third normal form. Each of these forms has a set of rules to ensure that your database complies with the form. Each of the forms builds on the previous forms.

The first normal form

...

Types of RDMS

An RDMS is a database that stores data in tables using rows and columns. The values in the tables are related to one other, and the tables may also be related to one another, hence the term relational. This relationship makes it possible to access data across multiple tables with a single query.

In this section, we will review the top four relational database management systems. The top four are Oracle, MySQL, SQL Server, and PostgreSQL.

According to the DB-Engines Ranking, here are the scores for the top RDMSes at the time of writing this book:

The preceding screenshot can be found at https://db-engines.com/en/ranking.

Oracle

Oracle was first released in 1979. Oracle was the first commercially available SQL...

Summary

This chapter introduced the concepts required to understand the basics of relational database management systems. It introduced you to foundational topics such as understanding SQL, what SQL can do, and its basic components. You learned that there are three subdivisions of SQL called DML, DDL, and DCL, and that the SQL language is comprised of several elements that make up a statement. We walked through a description of the relational model, what a database is, and what is in a database, including what a table, row, column, and field are.

We followed with an explanation of data integrity, including the different types of data integrity, such as entity, referential, and domain integrity, and looked at how to use keys and constraints. This understanding of data integrity helped you understand database normalization, including the different forms of normalization, 1NF, 2NF...

Questions

  1. What is SQL?
  2. What are the different subdivisions of SQL?
  3. What are the elements of a SQL statement?
  4. What are the reasons to normalize a database?
  5. What are the levels of database normalization?
  6. What is data integrity?
  7. What are the different ways you can enforce data integrity?
  8. What types of RDMS exist?
  9. What is the main advantage of MySQL?
  10. What is the main disadvantage of Oracle and SQL Server?
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore all SQL statements in depth using a variety of examples
  • Get to grips with database querying, data aggregate, manipulation, and much more
  • Understand how to explore and process data of varying complexity to tell a story

Description

SQL is a powerful querying language that's used to store, manipulate, and retrieve data, and it is one of the most popular languages used by developers to query and analyze data efficiently. If you're looking for a comprehensive introduction to SQL, Learn SQL Database Programming will help you to get up to speed with using SQL to streamline your work in no time. Starting with an overview of relational database management systems, this book will show you how to set up and use MySQL Workbench and design a database using practical examples. You'll also discover how to query and manipulate data with SQL programming using MySQL Workbench. As you advance, you’ll create a database, query single and multiple tables, and modify data using SQL querying. This SQL book covers advanced SQL techniques, including aggregate functions, flow control statements, error handling, and subqueries, and helps you process your data to present your findings. Finally, you’ll implement best practices for writing SQL and designing indexes and tables. By the end of this SQL programming book, you’ll have gained the confidence to use SQL queries to retrieve and manipulate data.

What you will learn

Install, configure, and use MySQL Workbench to restore a database Explore different data types such as string, numeric, and date and time Query a single table using the basic SQL SELECT statement and the FROM, WHERE, and ORDER BY clauses Query multiple tables by understanding various types of table relationships Modify data in tables using the INSERT, UPDATE, and DELETE statements Use aggregate functions to group and summarize data Detect bad data, duplicates, and irrelevant values while processing data

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
Buy Now

Product Details


Publication date : May 29, 2020
Length 564 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781838984762
Category :

Table of Contents

24 Chapters
Preface Chevron down icon Chevron up icon
Section 1: Database Fundamentals Chevron down icon Chevron up icon
Introduction to Relational Database Management Systems Chevron down icon Chevron up icon
Installing and Using MySQL Workbench Chevron down icon Chevron up icon
Understanding Data Types Chevron down icon Chevron up icon
Designing and Creating a Database Chevron down icon Chevron up icon
Importing and Exporting Data Chevron down icon Chevron up icon
Section 2: Basic SQL Querying Chevron down icon Chevron up icon
Querying a Single Table Chevron down icon Chevron up icon
Querying Multiple Tables Chevron down icon Chevron up icon
Modifying Data and Table Structures Chevron down icon Chevron up icon
Section 3: Advanced SQL Querying Chevron down icon Chevron up icon
Working with Expressions Chevron down icon Chevron up icon
Grouping and Summarizing Data Chevron down icon Chevron up icon
Advanced Querying Techniques Chevron down icon Chevron up icon
Programmable Objects Chevron down icon Chevron up icon
Section 4: Presenting Your Findings Chevron down icon Chevron up icon
Exploring and Processing Your Data Chevron down icon Chevron up icon
Telling a Story with Your Data Chevron down icon Chevron up icon
Section 5: SQL Best Practices Chevron down icon Chevron up icon
Best Practices for Designing and Querying Chevron down icon Chevron up icon
SQL Appendix Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
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.