Home » Tag Archives: Databases (page 4)

Tag Archives: Databases

SQL Tip of the Day: Be Wary of SELECT COUNT(*)

software-development-2-logo

Recently, I’ve encountered this sort of query all over the place at a customer site:                     DECLARE v_var NUMBER(10); BEGIN SELECT COUNT(*) INTO v_var FROM table1 JOIN table2 ON table1.t1_id = table2.t1_id JOIN table3 ON table2.t2_id = table3.t2_id ... WHERE some_predicate; IF (v_var = 1) THEN do_something ELSE do_something_else END IF; ...

Read More »

Are You Using SQL PIVOT Yet? You Should!

software-development-2-logo

Every once in a while, we run into these rare SQL issues where we’d like to do something that seems out of the ordinary. One of these things is pivoting rows to columns. A recent question on Stack Overflow by Valiante asked for precisely this. Going from this table:             +------+------------+----------------+-------------------+ | dnId | propNameId ...

Read More »

PostgreSQL’s Table-Valued Functions

postgresql-logo

Table-valued functions are an awesome thing. Many databases support them in one way or another and so does PostgreSQL. In PostgreSQL, (almost) everything is a table. For instance, we can write:                 CREATE OR REPLACE FUNCTION f_1 (v1 INTEGER, v2 OUT INTEGER) AS $$ BEGIN v2 := v1; END $$ LANGUAGE plpgsql; … ...

Read More »

Flyway and jOOQ for Unbeatable SQL Development Productivity

software-development-2-logo

When performing database migrations, we at Data Geekery recommend using jOOQ with Flyway – Database Migrations Made Easy. In this post, we’re going to look into a simple way to get started with the two frameworks.     Philosophy There are a variety of ways how jOOQ and Flyway could interact with each other in various development setups. In this ...

Read More »

Database primary key flavors

software-development-2-logo

Types of primary keys All database tables must have one primary key column. The primary key uniquely identifies a row within a table therefore it’s bound by the following constraints: UNIQUE NOT NULL IMMUTABLE When choosing a primary key we must take into consideration the following aspects:   the primary key may be used for joining other tables through a ...

Read More »

MySQL error: Can’t connect to MySQL server

mysql-logo

You may have stumbled on this MySQL error. If you have already seen this before, then it’s really easy to recognize this and fix it. But if you haven’t seen this error before, then it takes a little longer to troubleshoot the issue. I am listing down the steps to troubleshoot this issue.               ...

Read More »

Yet Another 10 Common Mistakes Java Developers Make When Writing SQL (You Won’t BELIEVE the Last One)

software-development-2-logo

(Sorry for that click-bait heading. Couldn’t resist!) We’re on a mission. To teach you SQL. But mostly, we want to teach you how to appreciate SQL. You’ll love it! Getting SQL right or wrong shouldn’t be about that You’re-Doing-It-Wrong™ attitude that can be encountered often when evangelists promote their object of evangelism. Getting SQL right should be about the fun ...

Read More »

MySQL Transaction Isolation Levels and Locks

mysql-logo

Recently, an application that my team was working on encountered problems with a MySQL deadlock situation and it took us some time to figure out the reasons behind it. This application that we deployed was running on a 2-node cluster and they both are connected to an AWS MySQL database. The MySQL db tables are mostly based on InnoDB which ...

Read More »

Seven Databases in Seven Weeks – Hbase Day 2

apache-hbase-logo

This post is a recap of the second day of Hbase from the Seven Databases in Seven Weeks book. Most of the commands and scripts can be found at GitHub: https://github.com/eyalgo/seven-dbs-in-seven-weeks/tree/master/hbase/day_2 Streaming Script The first thing in day 2 was to download lots of data (big data) and stream it into Hbase. There’s a JRuby script, which I had to ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close