Databases with SQLite

Now What?

Now that we've designed, normalized, and populated our database, what do we do with it?

If this sounds like a dumb question, bear with me. I was once a dummy.

Of course the whole point of building the database is so that we can now pull or extract 'useful' data out of it. Depending on your actual situation, this may become another rabbit hole you need to dig into and understand, or it may be a slight, uphill curve in the road.

As may be expected, there are various ways to do these extractions:

We also should consider the purpose of a particular database.

Another situation might be what environment you are doing your database management in:


Compound Operators

There are several ways to pull data out, usually all involving the select statement.

One way is with compound operators, named that because they are typically used with multiple select queries.

They are also known as set operators, and we will use Venn diagrams to represent them visually.

We will be using the following 2 tables:

CREATE TABLE a1 (c1 INT);

INSERT INTO
a1 (c1)
VALUES
(1),
(2),
(3),
(4);

CREATE TABLE a2 (c2 INT);

INSERT INTO
a2 (c2)
VALUES
(2),
(3),
(4),
(6);
In compound statements,
the queries must have the same number of columns,
and the columns must be of compatible data types.

SQLite has 4 compound operators availble:

Joins 01