Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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

Arrow left icon
Profile Icon Josephine Bush
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (6 Ratings)
Paperback May 2020 564 pages 1st Edition
eBook
$20.98 $29.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Josephine Bush
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (6 Ratings)
Paperback May 2020 564 pages 1st Edition
eBook
$20.98 $29.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$20.98 $29.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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.

Who is this book for?

This book is for business analysts, SQL developers, database administrators, and students learning SQL. If you want to learn how to query and manipulate SQL data for database administration tasks or simply extract and organize relevant data for analysis, you’ll find this book useful. No prior SQL experience is required.

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

Product Details

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

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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
$279.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 $ 156.97
The SQL Workshop
$32.99
SQL for Data Analytics
$79.99
Learn SQL Database Programming
$43.99
Total $ 156.97 Stars icon
Banner background image

Table of Contents

23 Chapters
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

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(6 Ratings)
5 star 66.7%
4 star 0%
3 star 16.7%
2 star 16.7%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Alan Sep 13, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I studied relational database systems and SQL many years ago at post graduate level and needed to brush up on the subject. This book was exactly what I was looking for. The author is straight to the point and gives good examples. I enjoyed the book.
Subscriber review Packt
Matthew McDowell Nov 23, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Perfect beginner reference, the author has done a fantastic job! Easy to understand and a practical guide that can show you beginning steps to query a database as well as more advanced means off accessing and manipulating data. The book even goes into more advanced techniques for someone interested in database administration. This book goes over best practices in a clear manner with plenty of examples. As someone who works with relational databases on a daily basis, this book has helped me understand the fundamentals of what I knew how to do and has helped elevate the way I write queries. There is plenty left for me to learn and this book will continue to remain an invaluable tool!
Amazon Verified review Amazon
Bladwell Martinez Costas Jun 06, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Me agrado mucho este articulo.
Amazon Verified review Amazon
Vanessa Feb 13, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is very well-written and shows step by step how to manipulate data in SQL. It is written in an easy to read fashion, that helps the reader have an understanding of each query. There are many examples throughout to help show the process for a clear understanding of the fundamentals. There are also more advanced techniques shown, so the book isn't just for beginners either.
Amazon Verified review Amazon
Just Some Guy Jan 15, 2022
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
This isn't a bad book - it's actually pretty good. It's just not what the title claims. This book is good a good buy for 1 of these 2 use cases:1) You're brand new to using a real database (Excel and Access don't count), and you want a high-level introduction to using MySQL and writing SQL queries, etc.2) You're quite good with SQL and databases already, and you just want a reference on your desk you can flip open to check the syntax on part of your query, or similar reference-type needs.Besides that, I think this book is a miss. It's covers a lot of ground, but it moves really fast, and barely anything goes into much depth. As a result, if you're new to SQL then you won't actually *learn* much here (there are too few examples, and they never go into much depth) – but if you're a pro this is all pretty obvious, so you won't learn anything new.My main other complaint about this book is that for a book with "Programming" in the title, it barely meets that standard at all. Besides a quick pass on functions and stored procedures (which do involve programming via SQL), almost everything this book does is via the MySQL Workbench tool. Now, that's great if learning Workbench is your goal - but if you want to manage your database via APIs, or do anything programmatic whatsoever (via a language like Python, Java, etc.), this book has ZERO on ANY of that. The work "Programming" has no place in the title of this book.Two other minor complaints:1) There are some sloppy typos and technical errors that should have been caught by the editors - and that happened a couple times too many for me to ignore.2) The book really feels like the author was trying to pad the page count. There are a TON of screenshots (again, mostly of MySQL Workbench). While I usually like those, for reference, they were larger and more frequent than necessary. There are also pages of content that get very repetitive - like, the author would often repeat the same exact paragraph multiple times when explaining a list of things that were mostly the same, but had only slight differences. (for example, a full paragraph explaining an example with a logical TRUE/IN/= use case, and then the exact same paragraph repeated again but with just a couple words changed to explain the respective FALSE/NOT IN/!= use case). Pages of text could have been saved by using a more compact writing approach.All that said, this is a pretty good book for the 2 needs I mentioned at the top of this review. If that's you, buy it and make the most of it. But anyone wanting to really learn how to "program SQL" will need to read a few other books, too. Now you know.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.