Introduction to Databases

What is a database?

A collection of organized data

Like what?

  • Phone book
  • Library catalog
  • Medical records
  • School catalog

Notice that all of these collections of data existed before computers.

Storing Data on a Computer

Tables have records (rows) and fields (columns).

Database Management System

Computer application that is designed to store, analyze, and manipulate data.

Example databases

  • Access
  • Oracle
  • SQLite3
  • MySQL
  • PostgreSQL

The Four Major Functions

  • CREATE
INSERT INTO contacts (LastName, FirstName, PhoneNumber)
VALUES ("Smith", "John", "860-223-9038");
  • READ
SELECT * FROM contacts;
SELECT * FROM contacts WHERE LastName="Smith"
  • UPDATE
UPDATE contacts
SET PhoneNumber="392-394-9930"
WHERE LastName="Smith";
  • DESTROY
DELETE FROM contacts
WHERE LastName="Smith";

In addition to the major CRUD functions, database management systems can often process data.

Databases and Rails

  • What sort of data do web applications store in databases?
  • How does Rails (or any web application) interact with a database?

Questions?