<p><b>Learn everything you need to know to build efficient SQL queries using this easy-to-follow beginner's guide</b></p> <h4>Key Features</h4> <ul><li>Explore all SQL statements in depth using a variety of examples </li> <li>Get to grips with database querying, data aggregate, manipulation, and muc
Learn SQL Database Programming: Query and manipulate databases from popular relational database servers using SQL
â Scribed by Josephine Bush
- Publisher
- Packt Publishing
- Year
- 2020
- Tongue
- English
- Leaves
- 550
- Category
- Library
No coin nor oath required. For personal study only.
⌠Synopsis
Learn everything you need to know to build efficient SQL queries using this easy-to-follow beginner's guide
Key Features
- 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
Book 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
Who this book is 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.
Table of Contents
- Introduction to Relational Database Management Systems
- Installing and Using MySQL Workbench
- Understanding Data Types
- Designing and Creating a Database
- Importing and Exporting Data
- Querying a Single Table
- Querying Multiple Tables
- Modifying Data and Table Structures
- Working with Expressions
- Grouping and Summarizing Data
- Advanced Querying Techniques
- Programmable Objects
- Exploring and Processing Your Data
- Tell a Story with Your Data
- Best Practices for Design and Querying
- SQL Appendix
⌠Table of Contents
Cover
Title Page
Copyright and Credits
About Packt
Contributors
Table of Contents
Preface
Section 1: Database Fundamentals
Chapter 1: Introduction to Relational Database Management Systems
Understanding SQL
Elements of SQL
Understanding databases
Tables
Fields
Records or rows
Columns
Understanding data integrity
Types of integrity
Entity integrity
Unique constraints
Not null constraints
The primary key
Referential integrity
Domain integrity
Database normalizationÂ
The first normal form
The second normal form
The third normal form
Types of RDMS
Oracle
MySQL
SQL Server
PostgreSQL
RDMS SQL differences
Summary
Questions
Chapter 2: Installing and Using MySQL Workbench
Technical requirements
Installing MySQL Workbench
Installing on Windows
Installing MySQL on Windows
Configuring MySQL on WindowsÂ
Installing on MacÂ
Installing MySQL Server on MacÂ
Checking the status of MySQL Server on Mac
Installing MySQL Workbench on MacÂ
Using MySQL Workbench
Connecting to your local instance
Connecting to another instance or setting up your local instance
Restoring a databaseÂ
Summary
Questions
Chapter 3: Understanding Data Types
Understanding string data types
String data types in MySQL
MySQL string data type table summary
String data types in other RDMS
OracleÂ
PostgreSQL
SQL ServerÂ
String data types RDMS table comparison
Understanding numeric data types
Numeric data types in MySQLÂ
MySQL numeric data type table summary
Numeric data types in other RDMSes
SQL Server
Oracle
PostgreSQL
Numeric data types table comparison
Understanding date and time data types
Date and time data types in MySQLÂ
MySQL date and time data type table summary
Date and time data types in other RDMSes
OracleÂ
PostgreSQLÂ
SQL ServerÂ
Date and time data types table comparison
Understanding other data types
Other data types in MySQLÂ
Other data types in other RDMSes
OracleÂ
PostgreSQLÂ
SQL ServerÂ
Choosing the right data type
Examples of choosing a data typeÂ
Summary
Questions
Chapter 4: Designing and Creating a Database
Technical requirements
Creating a database
Guidelines for naming conventions
Avoiding keywords
Avoiding spacesÂ
Descriptive and accurate naming
Case and separating wordsÂ
Allowed characters when naming database objectsÂ
Learning how to create a database
Creating a database via the MySQL Workbench interface
Creating a database via MySQL Workbench with a SQL scriptÂ
Understanding SQL code errors
Understanding table relationships
Understanding entity-relationship diagrams
Understanding one-to-one table relationships
Understanding one-to-many table relationshipsÂ
Understanding many-to-many table relationships
Creating a table in the database
Understanding how to apply data types and data integrity to your table
Learning to create a database table
Natural and surrogate primary keysÂ
Creating a database table via MySQL Workbench
Creating a database table via MySQL Workbench with SQL scriptsÂ
Learning how to format SQL code for readability
Commenting SQL code
Understanding indexes
Understanding how indexing relates to data integrityÂ
Types of indexes
Understanding how indexing impacts performance
Understanding naming conventions for indexesÂ
SummaryÂ
Further reading
Questions
Chapter 5: Importing and Exporting Data
Technical requirements
Understanding table data import and export
Importing CSV files with table data import
Exporting to CSV files with table data export
Understanding SQL data import and export
Importing via data import in MySQL Workbench
Exporting via data export in MySQL Workbench
Understanding result data export
Exporting data directly from a result set
Understanding SQL syntax for importing and exporting dataÂ
Importing with a SQL script
Exporting with a SQL scriptÂ
Summary
Further reading
Questions
Section 2: Basic SQL Querying
Chapter 6: Querying a Single Table
Technical requirements
Using the SELECT statement and FROM clause
Understanding the SELECT statement and the FROM clause
Learning the correct order of other clauses you can use with SELECT
Understanding the different ways to query with a SELECTÂ statement
Learning how to use column aliases
Using the USE statement
Learning how to use the DISTINCT clauseÂ
Learning how to use the LIMIT clause
Limiting results on other Relational Database Management Systems (RDMSes)
Learning how to save a SQL query to a file
Learning how to open a SQL file
Learning how to add comments to your SQL code
Commenting code on other RDMSesÂ
Using the WHERE clause
Understanding how and when to use the WHERE clause to limit query results
Learning how to use the AND and OR operators
Learning how to use the NOT, IN, and BETWEEN operators
Learning how to use the LIKE operator and wildcards
Using the percent (%) wildcardÂ
Using the underscore (_) wildcard
Escaping wildcard valuesÂ
Differences between LIKE in other RDMSes
Learning how to filter on NULL values
Using the ORDER BY clause
Learning how to use the ORDER BY clause to order query results
Learning how to use the ORDER BY clause to sort by one or more columns
Using indexes with your queriesÂ
Learning how to see what indexes your query is using
Summary
Questions
Further readingÂ
Chapter 7: Querying Multiple Tables
Technical requirements
Understanding joinsÂ
Understanding results returned with an inner joinÂ
Understanding results returned with a left outer joinÂ
Understanding results returned with a right outer join
Understanding results returned with a full outer joinÂ
Using INNER JOINÂ
Learning INNER JOIN syntaxÂ
Learning how to use table aliasesÂ
Using OUTER JOINÂ
Learning LEFT OUTER JOIN syntax
Learning RIGHT OUTER JOIN syntax
Exploring differences in other relational data models
Using FULL OUTER JOIN
Using advanced joinsÂ
Understanding what a CROSS JOIN is and how to use itÂ
Understanding what a NATURAL JOIN is and how to use it
Understanding what a SELF JOIN is and how to use it
Understanding set theory
Understanding what a UNION join is and learning how to use it in a SQL query
UNION
UNION ALL
Understanding what an intersect is and learning how to use it in a SQL queryÂ
Looking at intersection in other RDMS
Understanding what difference is and learning how to use it in a SQL queryÂ
Exploring differences in other RDMS
EXCEPT
MINUS
Using indexes with your queriesÂ
SummaryÂ
Questions
Further readingÂ
Chapter 8: Modifying Data and Table Structures
Technical requirements
Inserting data into tables
Gathering information to insert, update, or delete data
Using the INSERT statementÂ
Single-row inserts
Multiple row inserts
Differences in other Relational Database Management Systems
Inserting data from one table into another table
Differences to other RDMSes
Deleting data from tables
Using the DELETE statement with a WHERE clause
Deleting all the data from a table
Learning an alternative way to delete data with the TRUNCATE statementÂ
Updating data in tables
Using the UPDATE statement with a WHERE clause
Updating all the data in a tableÂ
Updating table data from another existing tableÂ
Using transactions to save or revert changes
Understanding a SQL transaction
Learning the SQL syntax for SQL transactions
Differences in RDMS transaction syntax
Modifying the table structure
Adding a column
Dropping a column
Renaming a column
Changing the data type of a column
Adding or changing a column constraint
Dropping a constraint, key, or indexÂ
Differences to other RDMS
Dropping a table
SummaryÂ
QuestionsÂ
Further readingÂ
Section 3: Advanced SQL Querying
Chapter 9: Working with Expressions
Technical requirements
Using expressions
Literal valuesÂ
Operators
Comparison operatorsÂ
Logical operators
Mathematical operatorsÂ
Operator precedenceÂ
Column values
Built-in functions
String built-in functions
Differences in RDMS (Relational Database Management Systems)Â
Numeric built-in functionsÂ
Differences in RDMS
Datetime built-in functionsÂ
Working with time zonesÂ
Differences in RDMS
Advanced built-in functionsÂ
Working with NULL values
Differences in advanced built-in functions in RDMS
Built-in functions and indexingÂ
Using statistical functions
Learning how to use built-in statistical functions
Exploring differences in RDMSÂ
Using generated columnsÂ
Types of generated columnsÂ
Creating a generated columnÂ
Differences in RDMSes
SummaryÂ
QuestionsÂ
Further readingÂ
Chapter 10: Grouping and Summarizing Data
Technical requirements
Understanding aggregate functions
Numeric aggregate functionsÂ
Statistical aggregate functions
Using the GROUP BY clause
Understanding how GROUP BY works without aggregate functions
Using WHERE with GROUP BY
Using ORDER BY with GROUP BY
Learning how to use the GROUP BY clause to group query results using aggregate functions
Learning how to use the ROLLUP modifier
Differences in RDBMSesÂ
Using the HAVING clause
Learning how to use the HAVING clause to limit query results
Understanding the difference between the HAVING and WHERE clauses
Understanding SQL query order of executionÂ
SummaryÂ
QuestionsÂ
Chapter 11: Advanced Querying Techniques
Technical requirements
Using subqueries
Understanding the different types of subqueries and their usage
Using non-correlated subqueriesÂ
Using a non-correlated subquery in the WHERE clause
Using a non-correlated subquery in the SELECT clause
Using a non-correlated subquery in the FROM clause
Using INSERT, UPDATE, and DELETE with non-correlated subqueries
Differences between non-correlated subqueries in other relational database management systems (RDMSes)
Using correlated subqueriesÂ
Using a correlated subquery in the WHERE clause
Using a correlated subquery in the SELECT clause
Using common table expressions
Using non-recursive CTEs
Non-recursive CTE with the SELECT statementÂ
Using recursive CTEsÂ
Differences between CTEs in other RDMSes
Using query hints and transaction isolation levels
Understand the concepts of locking, blocking, and deadlocking
Learning how to use index hints to improve queries
Learning how to use transaction isolation levels
SummaryÂ
QuestionsÂ
Further readingÂ
Chapter 12: Programmable Objects
Technical requirements
Creating and using views
Learning how to create and query a view
Learning how to modify data returned in a view
Updating data using a view
Updating data using a view that has multiple tables
Inserting data using a view
Inserting data using a view that has multiple tables
Deleting data using a view
Deleting data using a view that has multiple tables
Learning how to update or delete a view
Differences between views in other relational database management systems (RDBMSes)Â
Creating and using variables
Learning how to create and assign values to variables
Learning how to use variables in SQL statements
Differences between variables in other RDBMSes
Creating and using stored procedures
Creating a stored procedure
Learning how to alter and drop stored proceduresÂ
Using variables and parameters in stored procedures
IN parameter
OUT parameter
Using flow control statements
Understanding the different types of flow control statements
Understanding the difference between the IF and CASE statements and how to use themÂ
Understanding how to loop through statements
Using error handling
Understanding error handling syntax and how to implement error handling
Differences between stored procedures in other RDBMSes
OracleÂ
Creating and calling a stored procedure in Oracle
Flow control in Oracle
Error handling in Oracle
PostgreSQL
Creating a stored procedure in PostgreSQLÂ
Flow control in PostgreSQLÂ
Error handling in PostgreSQL
SQL ServerÂ
Creating and calling a stored procedure in SQL ServerÂ
Flow control in SQL ServerÂ
Error handling in SQL ServerÂ
Creating and using functions
Understanding the difference between a function and a stored procedure
Learning how to create and use functions
Learning how to alter or delete functionsÂ
Differences between functions in other RDBMSes
OracleÂ
PostgreSQLÂ
SQL ServerÂ
Creating and using triggers
Learning how to create and use a triggerÂ
Creating and using a trigger with one statement
Creating and using a trigger with multiple statements
Creating and using multiple triggers on the same tableÂ
Deleting a trigger
Differences between triggers in other RDBMSes
Creating and using temporary tables
Learning how to create and use a temporary table
Learning how to delete a temporary table
Differences between temporary tables in other RDBMSes
SummaryÂ
Questions
Further readingÂ
Section 4: Presenting Your Findings
Chapter 13: Exploring and Processing Your Data
Technical requirements
Exploring your dataset
Getting to know your data using statistical identities
Detecting rare and outlier values
Detecting missing values
Detecting duplicate and erroneous valuesÂ
Consulting with experts or becoming the expert
Creating a data dictionary
Using regular expressions
Combining regular expression charactersÂ
Processing your dataset
Fixing rare and outlier values
Fixing missing values
Removing or fixing duplicatesÂ
Removing duplicatesÂ
Fixing duplicatesÂ
Fixing erroneous dataÂ
SummaryÂ
QuestionsÂ
Chapter 14: Telling a Story with Your Data
Technical requirements
Finding a narrative
Types of data stories
Asking questions to find your narrativeÂ
Using the statistical identity of your data to determine a narrative
Knowing your audience
Determining who your audience is
Creating a compelling presentation for your audience
Determining a presentation framework
Explaining the question
Explaining the answer
Explaining your methodology
Using visualizations
Common mistakes to avoid in visualizationsÂ
Using data visualization tools
SummaryÂ
QuestionsÂ
Section 5: SQL Best Practices
Chapter 15: Best Practices for Designing and Querying
Technical requirements
Best practices for database design
Understanding data integrity
Naming conventions of database objects
Understanding what data types to use
Best practices for indexing
Understanding when to create indexes
Best practices for querying and modifying data
Understanding how to write clean code
Understanding query optimizationÂ
Understanding best practices when querying data
Understanding best practices when modifying data
SummaryÂ
Questions
Chapter 16: SQL Appendix
SQL for designing databases
Syntax for creating a database
Syntax for creating and altering tables
Syntax for creating and altering indexes
SQL for selecting data
Syntax for selecting dataÂ
Syntax for filtering dataÂ
Syntax for ordering results
Syntax for joining tablesÂ
Syntax for grouping results
Syntax for filtering grouped resultsÂ
Syntax for using aggregate functionsÂ
SQL for modifying data
Syntax for inserting data
Syntax for updating dataÂ
Syntax for deleting dataÂ
Syntax for SQL transactions
SQL expressions
Types of expressions
Syntax for using generated columnsÂ
Advanced query techniques
Syntax for subqueries
Syntax for common table expressions
Syntax for query hints
Syntax for transaction isolation levelÂ
Programmable objects
Syntax for views
Syntax for variables
Syntax for stored procedures
Syntax for flow control statements
Syntax for error handling
Syntax for functions
Syntax for triggers
Syntax for temporary tables
Summary
Assessments
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6Â
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Other Books You May Enjoy
Index
đ SIMILAR VOLUMES
Code .<p><b>Learn everything you need to know to build efficient SQL queries using this easy-to-follow beginner's guide</b></p> <h4>Key Features</h4> <ul><li>Explore all SQL statements in depth using a variety of examples </li> <li>Get to grips with database querying, data aggregate, manipulation, a
SQL DATABASE PROGRAMMING<br><br>The ability to use SQL (Structured Query Language) is a hugely powerful skill.<br>This book is, aimed at complete, beginners, and will, take you through all of the steps needed to master SQL.<br>You will learn how to use databases, the different SQL features, why you
Resilient T-SQL code is code that is designed to last, and to be safely reused by others. The goal of defensive database programming, the goal of this book, is to help you to produce resilient T-SQL code that robustly and gracefully handles cases of unintended use, and is resilient to common changes
Unlock the Power of Data with SQL Mastery! Are you eager to harness the full potential of databases and SQL for your career or personal projects? SQL Database Management and Query Language is your ultimate guide to mastering these essential skills. Whether you're a beginner looking to build a stron
Learn effective and scalable database design techniques in a SQL Server 2016 and higher environment. This book is revised to cover in-memory online transaction processing, temporal data storage, row-level security, durability enhancements, and other design-related features that are new or changed in