DEV Community

Danson Kuria
Danson Kuria

Posted on

From Tables to Insights: A Beginner's Journey into SQL

SQL is at its heart, the way we communicate with data. The first step is designing the "shape" of our data, which is frequently achieved using the CREATE TABLE statement: we define the columns and what data types they contain (INT, VARCHAR, etc), as well as any constraints (such as NOT NULL (must provide data) and UNIQUE (no duplicate data)). The process of creating the database, for example, the Greenwood Academy assignment, involved creating tables for students, subjects to study, and exam results, with each table having its own rules and structure.

When tables are created, they are not set in stone. ALTER TABLE is the place where we can change the name of a column or drop a column we no longer need, and modify the database to suit our evolving needs.

Next, I have learned to populate those tables with INSERT INTO, but I learnt that one has to use quotes for text and not for numbers — an important difference because that is how SQL interprets data types.

Once I have the data, the primary method of asking questions is to apply the SELECT statement. I use multiple WHERE clauses, BETWEEN, IN and LIKE to narrow results. I also use some summary functions, such as COUNT, and applied some intelligence to our queries, by using CASE WHEN to label the results, such as Distinction, Merit, Pass, Fail, based on custom logic.

The ability to create a table has evolved to the capability of filtering, updating and interpreting real data and making sense of it. These are the basic skills that every database professional needs every day, and they're just a few of many!

Top comments (0)