Database Basics for
New-ish Developers
HELLO!
I am Dave Stokes
I am a MySQL Community Manager
David.Stokes@Oracle.com @stokes
2
Database
A database is an organized collection of data stored and accessed
electronically from a computer system
3
Why Databases Are Hard
Different Mindset Than Programming 1 4
“
The relational model for database
management is an approach to managing
data using a structure and language
consistent with logic -- Wikipedia
5
Think of Data Being In Sets
◉ Data segmented by logical group
◉ Sales data
◉ Customer information
◉ Shipping
◉ Production
◉ Join various logical groups together when needed
◉ Eliminate redundancy
6
Works With Data Sets
Describe what you want the data
returned to you looks like.
Structured Query Language
1970s Design (but still relevant)
Designed to minimize data duplication.
Retrieve multiple records with one
command.
7
Procedural Programs
Data
Work with one record at a
time, looping to get others
Record
One row of data
Columns
Items of data
8
Database
Data
Table with sets of data,
multiple tables linked
together
Records
Sets of data filtered as
needed
Columns
Items of data
9
Your Database Server is like a library
Think of a table like a
book with all the
information on one
subject between the
covers.
Try to avoid tearing out
one page, reading that
page, and the going to
tear out the next page.
10
Getting Started With Databases
Open Source Database 2 11
Free Open Source Database
Many choices for software
Lots of documentation, examples, guides, videos on line
Reddit, forums, Slack, ...
Cloud options
12
How to learn
1. Try examples, make subtle changes
2. Break things, learn how to fix them
3. Create your own database from scratch
4. Work with your favorite programming language
13
Directed advice for programmers
1. Think in SETS!!!!
2. Check return codes for errors and warnings
3. Reinventing the wheel is a waste of time
a. Normalize data -- third normal form or better!
b. Think about how you are using the data, build architecture
around that use.
4. Object Relational Mappers are extra complexity
a. LEARN SQL
14
15
Structured Query Language
SQL 316
17
Declarative Language
Tell the server what you want
18
Dave’s Pizza Analogy
SQL
Specify crust
Specify sauce
Specify toppings
Your Programming Language
Grow wheat for crust
Harvest wheat for crust
Turn wheat into flour
Obtain water to mix with flour
Find Stirring tool
Mix water and flour in bowl
Check dough consistency
Let dough rise
Shape dough
19
Declarative Language
In a similar sense to object–relational impedance mismatch, a
mismatch occurs between the declarative SQL language and the
procedural languages in which SQL is typically embedded.
Example: Your Own Shipping Department
Orders Table
List of items ordered by
customers
20
Customers Table
Get customer payment and
shipping information
Shipping Table
Pack/ship orders
Example: Your Own Shipping Department
Orders Table
List of items ordered by
customers
21
Customers Table
Get customer payment and
shipping information
Shipping Table
Pack/ship orders
Example: Your Own Shipping Department
Orders Table
List of items ordered by
customers
22
Customers Table
Get customer payment and
shipping information
Shipping Table
Pack/ship orders
23
Sold but not shipped
Shipping issues?
Free stuff?
Orders processed
What information is available?
24
SELECT customer.name,
order.number,
customer.shiping_address
FROM customer
JOIN order on (order.customer_id = customer.customer_id)
WHERE order.shipped = 0
AND order.packed = 1
AND order.paid_ok = 1;
Example query to determine orders that are ready to ship.
Test Drive MySQL
Database Service For
Free Today
Get $300 in credits
and try MySQL Database Service
free for 30 days.
https://www.oracle.com/cloud/free/
Copyright © 2021, Oracle and/or its affiliates
25
26
Please Buy My Book
If you are interested in the JSON data type in
MySQL or the NoSQL JSON Document Store
then you need this book!
Available on Amazon.com!
THANKS!
Any questions?
You can find me at
@stoker / david.stokes@oracle.com
&
MySQL Booth on Virtual Expo Hall
27
Slides at slideshare.net/davestokes

Database basics for new-ish developers -- All Things Open October 18th 2021

  • 1.
  • 2.
    HELLO! I am DaveStokes I am a MySQL Community Manager David.Stokes@Oracle.com @stokes 2
  • 3.
    Database A database isan organized collection of data stored and accessed electronically from a computer system 3
  • 4.
    Why Databases AreHard Different Mindset Than Programming 1 4
  • 5.
    “ The relational modelfor database management is an approach to managing data using a structure and language consistent with logic -- Wikipedia 5
  • 6.
    Think of DataBeing In Sets ◉ Data segmented by logical group ◉ Sales data ◉ Customer information ◉ Shipping ◉ Production ◉ Join various logical groups together when needed ◉ Eliminate redundancy 6
  • 7.
    Works With DataSets Describe what you want the data returned to you looks like. Structured Query Language 1970s Design (but still relevant) Designed to minimize data duplication. Retrieve multiple records with one command. 7
  • 8.
    Procedural Programs Data Work withone record at a time, looping to get others Record One row of data Columns Items of data 8
  • 9.
    Database Data Table with setsof data, multiple tables linked together Records Sets of data filtered as needed Columns Items of data 9
  • 10.
    Your Database Serveris like a library Think of a table like a book with all the information on one subject between the covers. Try to avoid tearing out one page, reading that page, and the going to tear out the next page. 10
  • 11.
    Getting Started WithDatabases Open Source Database 2 11
  • 12.
    Free Open SourceDatabase Many choices for software Lots of documentation, examples, guides, videos on line Reddit, forums, Slack, ... Cloud options 12
  • 13.
    How to learn 1.Try examples, make subtle changes 2. Break things, learn how to fix them 3. Create your own database from scratch 4. Work with your favorite programming language 13
  • 14.
    Directed advice forprogrammers 1. Think in SETS!!!! 2. Check return codes for errors and warnings 3. Reinventing the wheel is a waste of time a. Normalize data -- third normal form or better! b. Think about how you are using the data, build architecture around that use. 4. Object Relational Mappers are extra complexity a. LEARN SQL 14
  • 15.
  • 16.
  • 17.
  • 18.
    18 Dave’s Pizza Analogy SQL Specifycrust Specify sauce Specify toppings Your Programming Language Grow wheat for crust Harvest wheat for crust Turn wheat into flour Obtain water to mix with flour Find Stirring tool Mix water and flour in bowl Check dough consistency Let dough rise Shape dough
  • 19.
    19 Declarative Language In asimilar sense to object–relational impedance mismatch, a mismatch occurs between the declarative SQL language and the procedural languages in which SQL is typically embedded.
  • 20.
    Example: Your OwnShipping Department Orders Table List of items ordered by customers 20 Customers Table Get customer payment and shipping information Shipping Table Pack/ship orders
  • 21.
    Example: Your OwnShipping Department Orders Table List of items ordered by customers 21 Customers Table Get customer payment and shipping information Shipping Table Pack/ship orders
  • 22.
    Example: Your OwnShipping Department Orders Table List of items ordered by customers 22 Customers Table Get customer payment and shipping information Shipping Table Pack/ship orders
  • 23.
    23 Sold but notshipped Shipping issues? Free stuff? Orders processed What information is available?
  • 24.
    24 SELECT customer.name, order.number, customer.shiping_address FROM customer JOINorder on (order.customer_id = customer.customer_id) WHERE order.shipped = 0 AND order.packed = 1 AND order.paid_ok = 1; Example query to determine orders that are ready to ship.
  • 25.
    Test Drive MySQL DatabaseService For Free Today Get $300 in credits and try MySQL Database Service free for 30 days. https://www.oracle.com/cloud/free/ Copyright © 2021, Oracle and/or its affiliates 25
  • 26.
    26 Please Buy MyBook If you are interested in the JSON data type in MySQL or the NoSQL JSON Document Store then you need this book! Available on Amazon.com!
  • 27.
    THANKS! Any questions? You canfind me at @stoker / david.stokes@oracle.com & MySQL Booth on Virtual Expo Hall 27 Slides at slideshare.net/davestokes