FOUNDATIONS OF DIGITAL BUSINESS:
DATABASES
Shankar Venkatagiri
January 2023
Overview
• Relational databases • Querying with SQL
• Unstructured data • Demo
Databases
• Database software platforms allow users to
store and manage data
– And issue queries!
• Tabular data is the focus of relational database
management systems (RDBMS)
– MySQL and Hive are open source
– Oracle, SQLServer, DB2, …
Unstructured
• Not all data is amenable
to RDBMS storage
– E.g. Tweets
• NoSQL systems
– MongoDB – open source
– Aerospike, Couchbase, …
• Graph DBs
– Neo4J, Amazon Neptune
JSON
• Javascript Online Notation
– Key-value pairs
{“created”: ”Sep 30, 2018 [Link]”,
“screenname”:”ArtsandClouds”,
“text”:”Now this is really funny...”,
“entities”:
{“hashtags”:[“AI”,
“ArtificialIntelligence”,
“BigBrotherIsWatching”,
“BigData”, ...],
“image”: ... }
BankMarketing
job education month
admin. 1 jan 1
primary 1
blue-collar 2 feb 2
entrepreneur 3 secondary 2 mar 3
housemaid 4 tertiary 3 apr 4
management 5 unknown 4 may 5
retired 6 jun 6
self-employed 7 jul 7
services 8 aug 8
student 9 marital sep 9
technician 10 divorced 1 oct 10
unemployed 11 married 2 nov 11
unknown 12 dec 12
single 3
E-R job
id type
job format 1 admin.
id int 2 blue-collar
bank_calls format
type varchar(25) 3 entrepreneur
id int
… …
age int month
12 unknown
job_id varchar(25) marital format
id type
marital_id int id int marital 1 jan
education_id int status varchar(10) id type 2 feb
… 1 divorced 3 mar
balance int 2 married … …
education format
… 3 single 12 dec
id int
month_id int
level varchar(10)
education
y varchar(1) id type
month format
1 primary
id int
2 secondary
name varchar(10)
3 tertiary
4 unknown
SQL
• SQL – Structured Query Language
– Simple way to interact with an RDBMS
• One language, multiple purposes
• Define - create/alter/drop table
• Control - grant/revoke privilege
• Manipulate - insert/update/delete row
• Query - select
Query
• SELECT <<columns>>
• FROM <<tables>>
• WHERE <<conditions>>
• GROUP BY <<columns>>
• ORDER BY <<columns>> DESC/ASC
Demo
• BankMarketing example
– Created a database named bank_marketing
– Tables: calls,job,marital,education,…
Type in a
SQL query
• We use a tool called MySQL Workbench
– Product of Oracle Corporation
– Allows users to interact intuitively with DB
Model
• Can reverse-engineer the E-R diagram
Join
• To answer business questions, we must often
join multiple tables
– With real business data, queries can get slow
Scale
• Spreadsheet-like operations
– Pivot table aggregation
Thank You!
Indian Institute of Management Bangalore
Bannerghatta Road, Bangalore – 560 076, INDIA
[Link]