Michael J. Hernandez, John L

Over the past few years, SQL has gone from being a language known only to computer scientists to being widely used. international standard. The total number of SQL-compatible databases shipped each year now numbers in the millions. If you are contacting corporate information on the Internet or over an internal network, then you are probably using SQL. SQL Queries for Mere Mortals helps beginners learn the basics of SQL queries and is an essential reference guide for experienced and advanced users.


Content.
Part I Relational Databases and SQL. 1
Chapter 1 What is “relational”? 3
Database types3
Brief history relational model. 4
Anatomy of relational databases. 5
Why is all this needed? 14
Results.16
Chapter 2 Ensuring the reliability of the database structure. 17
Why is this chapter placed here? 17
Why do you need a well thought out structure? 18
Setting up fields. 18
Setting up tables. 26
Installing and correcting connections. 36
And that's all? 43
Results. 43
Chapter 3 A Brief History of SQL. 45
Origins of SQL. 45
Early implementations. 47
".and then there was the Standard." 48
Development of the ANSI/ISO standard. 49
What the future holds. 54
Why learn SQL. 56
Results. 57
Part II SQL Basics. 59
Chapter 4 Creating simple queries. 61
Introduction to SQL. 61
SELECT statement. 62
A short digression: Data versus information.64
Translating the query into SQL. 66
Eliminate duplicate rows.72
Sorting information. 74
Job Saving79
Operator examples. 79
Results.87
Tasks for independent decision. 88
Chapter 5 How to get more than just columns. 91
SELECT condition, take two.92
Beyond the basics96
What is an "expression"97
What are you trying to express.97
Types of expressions. 100
Using Expressions in a SELECT Condition. 109
Null value. 117
Operator examples. 120
Results.127
Problems for independent solution. 128
Chapter b Data filtering 131
Qualifying what was obtained using WHERE.131
Defining search terms.135
Using multiple conditions.156
Revisiting NULL: Warning Note.168
Expressing Conditions in various ways. 172
Operator examples. 173
Results.179
Problems for independent solution. 179
Part III Working with multiple tables. 183
Chapter 7 Thinking in sets. 185
What is a set? 186
Operations on sets.186
Intersection. 187
Difference. 192
Association. 199
Set operations in SQL. 203
Results.212
Chapter 8 Internal connections. 214
What is JOIN. 214
INNER JOIN. 215
Application of conditions INNER JOIN.231
Examples of operators.233
Results.251
Problems for independent solution.251
Chapter 9 External connections.255
What is OUTER JOIN.255
LEFT/RIGHT OUTER JOIN.257
FULL OUTER JOIN.276
Using OUTER JOIN operations.281
Operator examples.282
Results.295
Problems for independent solution296
Chapter 10 UNION Operations 298
What is UNION.298
Writing queries with UNION.300
Application of UNION.311
Operator examples.312
Results.322
Problems for independent solution.322
Chapter 11* Subqueries325
What is a subquery.326
Subqueries as expressions with columns.327
Subqueries as filters.332
Using Subqueries.347
Examples of operators349
Results.361
Problems for independent solution.362
Part IV Summarizing data and grouping. 365
Chapter 12* Simple sum.367
Aggregate functions.367
Using aggregate functions in filters.381
Operator examples.384
Results.390
Problems for independent solution.390
Chapter 13 Grouping data. 393
Why do you need to group data.393
GROUP BY clause. 395
Imposing some restrictions.404
Using GROUP BY.408
Operator examples.409
Results.417
Problems for independent solution.418
Chapter 14 Filtering Grouped Data.420
Narrowing of groups.420
Filters: Feel the difference. 425
Using HAVING. 432
Operator examples. 433
Results. 441
Problems for independent solution. 441
Conclusion. 445
Applications 447
Appendix A SQL Standard Diagrams. 449
Appendix B Database structures used
as examples. 455
Appendix C Recommended reading. 459

Preface
SQL Queries for Mere Mortals is an excellent introduction to SQL queries and complements the previous book, Database Design for Mere Mortals, from Addison-Wesley. One might say that this is an even better introduction than the first book. A real programmer (that is, a mere mortal) spends more time writing SQL queries and less time designing the database itself. The schemes are created by highly paid database administrators who own private offices and sports cars. What most programmers do is try to make SQL work within a rigidly defined schema.
I set up databases and teach advanced SQL in my profession, so I can attest that most SQL texts are as readable as Egyptian hieroglyphs. Once a program starts working, the programmer who wrote it moves on to the next task, never looking back at what has been done. And when something goes wrong with this program, another person sends desperate messages to Internet discussion groups, where John and Mike will save him with a few words of wisdom and a rewrite of the code. They've been helping people solve their SQL problems for years. It's finally time to put it all into a book that anyone can use!


Free download e-book in a convenient format, watch and read:
Download the book SQL Queries for Mere Mortals, A Practical Guide to Data Manipulation in SQL, Michael J. Hernandez, John L. Viescas., 2003 - fileskachat.com, fast and free download.

Download pdf
You can buy this book below best price at a discount with delivery throughout Russia.

Databases General Michael J. Hernandez, John L. Viescas - SQL queries for mere mortals

Michael J. Hernandez, John L. Viescas - SQL queries for mere mortals

03.09.2009

The book SQL Queries for Mere Mortals is an excellent introduction to SQL queries. A real programmer (mere mortal) spends a lot of time writing SQL queries and less time designing the database itself. The schemes are created by highly paid database administrators who own private offices and sports cars. Most programmers are busy trying to make SQL work within a rigidly defined schema.

About the authors
Michael J. Hernandez is a well-known relational database consultant and owner of DataTex Consulting Group in Seattle. He often makes presentations at various conferences. He also wrote the book Database Design for Mere Mortals.

John L. Viescas- President of Viescas Consulting, Inc., a renowned database consulting firm. He is also the author of the best-selling book Running Microsoft Access 2000 and Programmer's Quick Reference Guide to SQL.

SQL for mere mortals + SQL in 10 minutes
Sams Teach Yourself SQL in 10 Minutes
Posted by Ben Forta
Translator: V. Ginzburg
Languages: Russian
Publisher: Williams
Series: Learn in 10 minutes
ISBN 978-5-8459-1858-1, 978-0-672-33607-2; 2014

Pages 288 pp.
Format 84x108/32 (130x200 mm)
Circulation 2000 copies.
Hardcover Paperback

The book SQL in 10 minutes offers simple and practical solutions for those who want to get results quickly. After working through all 22 lessons, each of which will take no more than 10 minutes, you will learn about everything you need to practical application SQL. The examples given in the book are suitable for IBM DB2, Microsoft Access, Microsoft SQL Server, MySQL, Oracle, PostgreSQL, SQLite, MariaDB and Apache OpenOffice Base.
access to all links
Visual examples will help you understand how SQL statements are structured.
Tips will suggest shortcuts to solutions.
Warnings will help you avoid common mistakes.
Notes will provide further clarification.
What you can learn in 10 minutes:


  • - basic SQL statements;
    - creating complex SQL queries with many clauses and operators;
    - extracting, sorting and formatting data;
    - obtaining specific data using various methods filtration;
    - application of summary functions to obtain summary data;
    - combining relational tables;
    - adding, updating and deleting data;
    - creating and changing tables;
    - working with views, stored procedures and much more.
Ben Forta is director of development at Adobe Systems. Author of numerous best-selling books, including books on databases, SQL, and ColdFusion. Has extensive experience in database design and application development.

Understanding SQL
Author: Martin Graber
Translator: V. Yastrebov
Languages: Russian
Publisher: Lori
ISBN 978-5-85582-301-1; 2014
Additional Features
Pages 378 pp.
Format 70x100/16 (170x240 mm)
Circulation 200 copies.
Hardcover Paperback

SQL FOR MERE MORTALS is a complete introduction to a structured query language, written specifically for beginners. If you have no experience managing databases, this book will teach you how to work with SQL easily and fluently, using simple queries and complex operations. To master SQL:
- Understand the concepts associated with database management with a short and simple introduction to relational databases.
- Follow these instructions to use basic SQL commands to find and manipulate information in data tables. Learn to select, summarize, and manage data skillfully.
- Work effectively with compound data tables by applying advanced query techniques to more than one table at a time, constructing complex queries and subqueries.
- Create new data tables for trading business applications. Explore important principles effective database design and techniques for ensuring data integrity and protection.
- Learn to use SQL with programming languages ​​using a special chapter for programmers.

SQL FOR MERE MORTALS is an essential guide for any implementation of the language structured queries, which includes a quick reference to standard SQL and a description of common properties of non-standard SQL.



SQL FOR MERE MORTALS is a complete introduction to a structured query language, written specifically for beginners. If you have no experience managing databases, this book will teach you how to work with SQL easily and fluently, using simple queries and complex operations. To master SQL:

  • Understand the concepts associated with database management with a short, simple introduction to relational databases.
  • Follow these instructions to use basic SQL commands to find and manipulate information in data tables. Learn to select, summarize, and manage data skillfully.
  • Work effectively with compound data tables by applying advanced query techniques to more than one table at a time, constructing complex queries and subqueries.
  • Create new data tables for trading business applications. Learn important principles of effective database design and techniques for ensuring data integrity and security.
  • Learn to use SQL with programming languages ​​using a special chapter for programmers.

SQL FOR MERE MORTALS is an essential guide to any implementation of a structured query language, including a quick reference to standard SQL and a description of the general properties of non-standard SQL.

1. Introduction to relational databases
2. Introduction to SQL
3. Using SQL to retrieve data from tables
4. Using relational and Boolean operators to create more complex predicates
5.Usage special operators in “conditions”
6. Summarizing data using aggregation functions
7. Formatting query results
8. Using multiple tables in one query
9. Join operation, the operands of which are represented by one table
10. Nesting queries
11. Related subqueries
12. Using the EXISTS operator
13. Using the ANY, ALL and SOME operators
14. Using the UNION clause
15. Entering, deleting and changing field values
16. Using subqueries with update commands
17. Creating tables
18. Restrictions on the set of valid data values
19. Maintain data integrity
20. Introduction to Views
21. Changing Values ​​Using Views
22. Determining data access rights
23. Global Aspects of SQL
24. How to maintain order in the database SQL data
25. Using SQL with other programming languages ​​(embedded SQL)
Applications
A. Answers to exercises
B. SQL Data Types
C. Some Common Deviations from the SQL Standard
D. Syntax and Command Help
E. Tables used in examples
F. SQL Today

Introduction to Relational Databases

... We will also use both terms as synonyms when discussing SQL. You are already familiar with simple tables. For all their brevity and simplicity, they are quite suitable for demonstrating the most important features of the language, as you will see for yourself later. Sometimes we will introduce other tables or look at other data in one of these tables in order to show some additional features their applications. Now we're ready to dive straight into SQL. Next chapter, to
which you will have to return to from time to time, gives a general idea of ​​the language and orients you in the material presented in the book.

Introduction to SQL

This chapter covers a lot of basic information to give you an overview of SQL. You learned how it is structured, how it is used, how it expresses data, how and by whom it is defined (and the tensions that arise), and some of the conventions and terminology used to describe it. The next chapter explains in detail the formation and operation of commands. You'll learn about a command that allows you to retrieve information from tables and is one of the most commonly used commands in SQL. You will be able to retrieve certain information from the database yourself.

Global Aspects of SQL

  • Synonyms (how to create new names for data objects)
  • Database space (dbspace) (how to partition the space available in a database)
  • Transaction processing (how to save or discard changes to the database)
  • Concurrency control (how SQL allows you to prevent commands from interfering with each other)

Synonyms are objects, have names and (sometimes) owners, but do not exist independently of the table whose name they replace. They can be shared and therefore accessible to everyone with access to the object, or they can be owned only by a specific user. Dbspaces are database subsections allocated to users. Related tables that frequently undergo a join operation are best stored in the same database space. COMMIT and ROLLBACK are commands used to save as a group all changes to the database since the previous COMMIT or ROLLBACK command or the start of a session, or to abandon them. Concurrency control determines the extent to which concurrent commands affect each other. This is where operational differences emerge in how databases operate and how commands are isolated.

How to Maintain Order in a SQL Database

So, SQL systems use a set of tables called the system directory of the database structure. These tables can be queried, but cannot be updated. You can also add (or delete) comment columns to the SYSTEMCATALOG and SYSTEMCOLUMNS tables. Creating views on these tables is an excellent way to define exactly what information users are authorized to access. This concludes our discussion of SQL in interactive mode. The next chapter will look at how to use SQL directly in programs written in programming languages; This use allows you to take advantage of the program's interaction with the database.

Using SQL with other programming languages ​​(embedded SQL)

SQL commands are included in procedural programming languages ​​to combine the strengths of the two approaches. Implementing this feature requires some SQL extensions. Embedded SQL commands are translated by a program called a precompiler (preprocessor) to produce a program that can be understood by a high-level language compiler. Embedded SQL commands are replaced by calls to routines that are created using the embedded preprocessor; these routines are called access modules. Using this approach, ANSI supports embedded SQL for languages Pascal programming, FORTRAN, COBOL, PL/1. Other languages ​​are also used by developers. The most important of these is C. When describing embedded SQL, special attention should be paid to the following:

  • All built-in SQL commands begin and end with EXEC SQL depending on the high-level language used.
  • All high-level language variables used in SQL commands must be included in the section SQL descriptions before its use.
  • If high-level language variables are used in SQL commands, their names must be preceded by a colon.
  • The output of queries can be stored directly in high-level language variables using INTO if and only if the query selects a single row.
  • Cursors can be used to store query output and access it one row at a time. Cursors are declared (along with a definition of the query whose output the cursor contains), opened (which corresponds to the execution of the query), and closed (which corresponds to the removal of the output from the cursor, breaking the connection between the output and the cursor). While the cursor is open, you can use the FETCH command to access the output of the query: one row for each execution of the FETCH command.
  • Cursors can be updatable or read-only. To be updatable, a cursor must meet all the same criteria as a view. It must not use the ORDER VU and UNION clauses, which are prohibited from being used in the view. A cursor that is not updated is a read-only cursor.
  • If the cursor is updatable, it can be used to manipulate rows that are used by the embedded SQL UPDATE and DELETE commands in the WHERE CURRENT OF clause. The DELETE or UPDATE must belong to the table being accessed through the query cursor.
  • SQLCODE can be declared as a numeric variable for every program that uses embedded SQL. The values ​​of this variable are set automatically after each SQL command is executed.
  • If the SQL command runs normally but does not produce output or does not make the expected changes to the database, SQLCODE is set to 100. If the command fails, SQLCODE is set to some negative value that describes the cause of the error, depending on the specific SQL system. Otherwise, SQLCODE is zero.
  • The WHENEVER clause can be used to determine what action to take if SQLCODE is 100 (NOT FOUND) or negative (SQLERROR). This action consists of going to some specific point in the program (GOTO<метка>) or to perform an “empty action” (CONTINUE, equivalent to the concept of “doing nothing”). The default is “empty action”.
  • Only numerical variables can be used as indicators. Indicator variables follow other variable names in the SQL command without any separating characters except the word INDICATOR.
  • Typically, the value of an indicator variable is O. If a SQL command attempts to place a NULL value in a high-level language variable that uses this indicator, it is assigned a negative value. This property can be used for error protection and as a flag to mark NULL values ​​in SQL that will be specially interpreted in the main program.
  • Indicator variables can be used to insert NULL values ​​into SQL INSERT or UPDATE commands. They take positive values ​​when a string truncation situation occurs.

Download the book SQL Queries for Mere Mortals

SQL Books - SQL Queries for Mere Mortals

Over the past few years, SQL has evolved from a language known only to computer scientists to a widely used international standard. The total number of SQL-compatible databases shipped each year now numbers in the millions. If you access corporate information on the Internet or over an intranet, then you probably use SQL. SQL Queries for Mere Mortals helps beginners learn the basics of SQL queries and is an essential reference guide for experienced and advanced users.

SQL queries for mere mortals. Description of the book on SQL

The book is an excellent introduction to SQL queries and complements well the previous book, Database Design for Mere Mortals, published by Addison-Wesley. One might say that this is an even better introduction than the first book. A real programmer (that is, a mere mortal) spends more time writing SQL queries and less time designing the database itself. The schemes are created by highly paid database administrators who own private offices and sports cars. What most programmers do is try to make SQL work within a rigidly defined schema.
I configure databases and teach advanced SQL in my profession, so I can confirm that most SQL texts are just as
attractive to read, just like Egyptian hieroglyphs. Once a program starts working, the programmer who wrote it moves on to the next task, never looking back at what has been done. And when something goes wrong with this program, another person sends desperate messages to Internet discussion groups, where John and Mike will save him with a few words of wisdom and a rewrite of the code. They have been helping people solve their problems related to SQL. It's finally time to put it all into a book that anyone can use!
It is not at all difficult and does not require any other time to write good program. If you understand what you are doing, then most problems can be solved quite simply. First of all, you need to learn the basics. This book gives you the chance to learn these basics in an understandable and well-written manner. Then you need to understand when and how to tailor a simple solution to a specific DBMS and a specific SQL implementation. When the basics are reliably mastered, contact me and I will teach you truly non-trivial things.

Share