Basic SQL Assignment

This assignment was completed through Gradescope and focused on core SQL operations on a provided schema. It served as students first introduction to implementing SQL queries with syntax that had just recently been introduced.

The submission format was a set of sql files (`query1.sql`, `query3.sql`, `query5.sql`, `query7.sql`, and `query8.sql`)

Assignment Scope

The work covered the basic fundamental query patterns: filtering, inserts, updates, deletes, and table creation with constraints.

Reflection

I recognize that AI tools can write many SQL queries very easily. Even so, building intuition through these exercises was valuable because in a real job environment I would imagine it is often quicker to write or adjust straightforward SQL directly than to prompt an LLM and validate every detail it returns.

Developing intuition also improves debugging speed. When a query result is wrong, knowing how SQL clauses interact makes it much easier to diagnose and fix the issue quickly.

Reference Query Code

Query 1

SELECT population FROM bsg_planets WHERE name = 'Caprica'

Query 2

SELECT fname,lname,age FROM bsg_people where lname != 'Adama' OR lname IS NULL;

Query 3

SELECT name,population FROM bsg_planets WHERE population > 2600000000;

Query 4

SELECT fname,lname,age FROM bsg_people WHERE age IS NULL;

Query 5

INSERT INTO bsg_planets (name,population,language,capital) VALUES ('Mars',2,'Binary','Olympus Mons');
SELECT * FROM bsg_planets where name = 'Mars';

Query 6

UPDATE bsg_people
SET age = 62
WHERE lname = 'Adama' AND fname = 'William';

SELECT * FROM bsg_people where lname = 'Adama' AND fname = 'William';

Query 7

DELETE FROM bsg_people
WHERE age IS NULL;

SELECT * FROM bsg_people WHERE age IS NOT NULL;

Query 8

CREATE TABLE bsg_spaceship (
    id INT NOT NULL AUTO_INCREMENT,
    name VARCHAR(255) NOT NULL,
    separate_saucer_section BOOLEAN NOT NULL DEFAULT FALSE,
    length INT NOT NULL,
    PRIMARY KEY (id)
);

DESCRIBE bsg_spaceship;