Databases and SQL for Data Science by IBM on Coursera
The hands-on labs for this course uses the IBM Cloud environment for working with a relational database. The database is created and accessed with IBM Db2 from the web browser.
This script contains basic sql commands for dropping tables, creating tables (with a primary key), inserting data into tables, and updating tables in the Db2 IBM Cloud database.
This script uses python to create and populate a pet sale table in the Db2 IBM Cloud database and to query the table with built-in functions including AVG, SUM, MAX, ROUND, COUNT, LENGTH, LCASE, UCASE, DISTINCT, CAST, DAY, MONTH, and CURRENT DATE.
This folder contains scripts for querying an HR database with advanced SQL commands.
- HR Database Tables.pdf illustrates the structure of the HR database.
- Script_Create_Tables.sql contains the code for creating the 5 HR database tables.
- Script_Query_HR_1.sql contains SQL queries with LIKE, BETWEEN, WHERE, ORDER BY, GROUP BY, COUNT, AVG, and HAVING clauses. It also contains a query that uses aliases and extracts information from two tables.
- Script_Query_HR_2.sql contains SQL queries with JOIN operations.
The data for the HR database was loaded into the Db2 database from CSV files.
This folder contains Jupyter Notebook scripts that connect to and query an IBM Db2 database.
- Connecting_to_Db.ipynb connects to a Db2 database on IBM Cloud using Python.
- Querying_Db.ipynb accesses a Db2 database on IBM Cloud using Python. This script also creates a table, inserts data, queries the data, and retrieves a result set into a Pandas data frame.
- SQL_magic.ipynb uses SQL Magic to accesse a Db2 database on IBM Cloud using Python. This script also uses SQL Magic to create a table, insert data, query the data, and retrieve a result set into a Pandas data frame.
- Analyzing_data.ipynb stores a dataset into a database from a .CSV file using Python. This script also queries and analyzes the data using SQL and Python.
This folder contains the Chicago Public School Progress Report files. This lab involved working with a real word dataset using SQL and Python to query columns with spaces or special characters in their names and with mixed names. It also required the use of built in database functions.
- CPS Progress Report 2011-12.csv is the dataset showing all school-level performance data used to create CPS School Report Cards for the 2011-2012 school year. The data was loaded into a Db2 database on IBM Cloud.
- CPS_reportcard_data_description.pdf contains descriptions of the report card dataset CPS Progress Report 2011-12.csv
- Chicago_school_progress.ipynb contains the scripts used to connect to and query the database.
This folder contains data files and a Jupyter Notebook script that demonstrates use of a variety of SQL commands to query the three datasets.
- Census_Data.csv contains six socioeconomic indicators of public health significance and a “hardship index,” by Chicago community area, for the years 2008 – 2012. For more detailed information, see the data description.
- Chicago_Crime_Data.csv reflects reported incidents of crime (with the exception of murders where data exists for each victim) that occurred in the City of Chicago from 2001 to present, minus the most recent seven days. For more detailed information, see the data description.
- Chicago_Public_Schools.csv shows all school level performance data used to create CPS School Report Cards for the 2011-2012 school year. For more detailed information, see the data description.
- Final_course_assignment.ipynb contains the script with ipython-sql code, which is used to query the datasets after they were loaded into a Db2 database on IBM Cloud.