Skip to content

devleague/SELECT-todo-FROM-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

SELECT todo FROM list

SQL CRUD Exercise in PostgreSQL

Prepare SQL statements while testing them on a local running database.

Docker Setup

Set your database name to be tasks.
Set your database username to be tasker.
Set your database password to be taskMaster.

To Do List Application

Write these SQL statements in todo_app.sql, and run them against your newly created database:

  1. Write a query to drop the table tasks if it exists.
  2. Write a query to create a table named tasks using the Initial columns detailed below
  3. Define column id as the table's primary key
  4. Write queries to accomplish the following
  5. remove the column named completed
  6. add a column to tasks named completed_at:timestamp, that may be NULL, and has a default value of NULL.
  7. change the updated_at column to not allow NULL values, and have a default value of now()
  8. create a new task, by only setting values (not defining which columns) id = default value
    title = 'Study SQL'
    description = 'Complete this exercise'
    created_at = now()
    updated_at = now()
    completed_at = NULL
  9. create a new task
    title = 'Study PostgreSQL'
    description = 'Read all the documentation'
  10. select all the titles of tasks that are not yet completed
  11. update the task with a title of 'Study SQL' to be completed as of now
  12. select all titles and descriptions of tasks that are not yet completed
  13. select all fields of every task sorted by creation date in descending order
  14. create a new task
    title = 'mistake 1'
    description = 'a test entry'
  15. create a new task
    title = 'mistake 2'
    description = 'another test entry'
  16. create a new task
    title = 'third mistake'
    description = 'another test entry'
  17. select title fields of all tasks with a title that includes the word 'mistake'
  18. delete the task that has a title of mistake 1
  19. select title and description fields of all tasks with a title that includes the word 'mistake'
  20. delete all tasks that includes the word 'mistake' in the title
  21. select all fields of all tasks sorted by title in ascending order

Initial Columns for tasks

Column Name Datatype NULL Default
id integer false auto incrementing
title character varying (255) false
description text true
created_at timestamp (no tz) false now()
updated_at timestamp (no tz) true
completed boolean false false

Final Columns for tasks

Column Name Datatype NULL Default
id integer false auto incrementing
title character varying (255) false
description text true
created_at timestamp (no tz) false now()
updated_at timestamp (no tz) false now()
completed_at timestamp (no tz) true NULL

About

SQL CRUD Exercise in PostgreSQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •