Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1
TIP

One of  the most    common  errors  among   new database    programmers is
confusing logical AND and logical OR. For example, in everyday speech,
you might say, “Find me all CDs released in 2003 and 2004.” At first
glance, you might think that if you fed this statement to the database in
SQL format, it would return the rows for For All You’ve Done and Life for
Rent. In fact, it would return no rows at all. This is because the database
interprets the statement as “Find all rows in which the CD was released in
2003 and was released in 2004.” It is, of course, impossible for the same
CD to be released twice without requiring a new ISBN and therefore a new
database entry, so this statement would never return any rows, no matter
how many CDs were stored in the table. The correct way to form this
statement is with an OR statement instead of an AND statement.

SQL is capable of far more than is demonstrated here. But as mentioned
earlier, this section is not intended to teach you all there is to know about SQL
programming; rather, it teaches you the basics so you can be a more effective
DBA.


Choosing a Database: MySQL Versus


PostgreSQL


If you are just starting out and learning about using a database with Linux, the
first logical step is to research which database will best serve your needs.
Many database software packages are available for Linux; some are free, and
others cost hundreds of thousands of dollars. Expensive commercial
databases, such as Oracle, are beyond the scope of this book. Instead, this
chapter focuses on two freely available databases: MySQL and PostgreSQL.


Both of these databases are quite capable, and either one could probably serve
your needs. However, each database has a unique set of features and
capabilities that might serve your needs better or make developing database
applications easier for you.


Speed


Until recently, the speed choice was simple: If the speed of performing
queries was paramount to your application, you used MySQL. MySQL has a
reputation for being an extremely fast database. Until recently, PostgreSQL
was quite slow by comparison.

Free download pdf