Navicat Blog

Storing Ternary Data In MySQL and PostgreSQL Dec 8, 2021 by Robert Gravelle

In software development, there is a Boolean data type for working with binary states. Hence, it only has two possible states: true and false. However, there exists a third state that must often be accounted for, and that is one for "none of the above" or simply "other". In relational databases, NULL might seem to be a good candidate for this state, but is not, due to its historical context. Recall from previous blogs that NULL has a very specific meaning in Structured Query Language (SQL) to indicate that a data value does not exist in the database. The NULL value was actually introduced by none other than the creator of the relational database model himself, E. F. Codd. In SQL, NULL has come to indicate "missing and/or inapplicable information". Seen in this light, NULL can hardly represent a "none of the above" or "other" condition. So then, what is the best way to represent ternary - or three-state - data in relational databases? We will answer that question here today for MySQL and PostgreSQL. Next week we'll cover SQL Server and Oracle.

The Perils of Testing SQL in Production Dec 1, 2021 by Robert Gravelle

i-dont-always-test-my-code-but-when-i-do-its-already-in-production

How many times have you found a query to be sufficiently performant when testing against sanitized data, only to see it stall once in production? It happens all the time, due to differences between the environments such as workload and volume of data. This may lead you to try out your query in production. After all, the fastest way to tune a query for production is on the production server, is it not? While correct, there are many dangers awaiting those foolish enough to tempt fate with such a cavalier disregard for safeguards and protocols. In this blog, we'll explore some of the risks associated with testing queries in production.

Unicode and Non-Unicode String Data Types in SQL Server Nov 19, 2021 by Robert Gravelle

SQL Server provides a number of data types that support all types of data that you may want to store. As you may have guessed, data type is an attribute that specifies the type of data that a column can store. It can be an integer, character string, monetary, date and time, and so on. One data type that causes some confusion among database designers and developers are those for storing character strings. A character string is a series of characters manipulated as a group. In the context of relational databases, character string data types are those which allow you to store either fixed-length (char) or variable-length data (varchar). Moreover, SQL Server splits its string types into two broad categories: Unicode and non-Unicode. These equate to nchar, nvarchar, and ntext for Unicode types and char, varchar/varchar (max) and text for non-Unicode. In today's blog, we'll compare the two categories to decide when to use one over the other.

The Purpose of WHERE 1=1 in SQL Statements Nov 8, 2021 by Robert Gravelle

Have you ever seen a WHERE 1=1 condition in a SELECT query. I have, within many different queries and across many SQL engines. The condition obviously means WHERE TRUE, so it's just returning the same query result as it would without the WHERE clause. Also, since the query optimizer would almost certainly remove it, there's no impact on query execution time. So, what is the purpose of the WHERE 1=1? That is the question that we're going to answer here today!

What Is SQLite and How Does It Differ from MySQL? Nov 2, 2021 by Robert Gravelle

SQLite and MySQL are equally popular open source Relational Database Management Systems (RDBMS). Both are fast, cross-platform, robust, and feature-rich. Yet, beyond these similarities, the two databases are dissimilar in several important respects. Since you are probably more familiar with MySQL, this tutorial will list SQLite's most important features, as well as dissimilitudes to MySQL, all with the goal of steering you towards the product that will best suit your needs.

Navicat Blogs
Feed Entries
Blog Archives
Share