+ All Categories
Home > Documents > Using Relational Databases and SQL

Using Relational Databases and SQL

Date post: 25-Feb-2016
Category:
Upload: ruana
View: 26 times
Download: 0 times
Share this document with a friend
Description:
Steven Emory Department of Computer Science California State University, Los Angeles. Using Relational Databases and SQL. Lecture 1: Introduction to Relational Databases and MySQL. Database Origin. Database comes from the open compound word “Data Base” - PowerPoint PPT Presentation
23
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 1: Introduction to Relational Databases and MySQL
Transcript
Page 1: Using Relational Databases and SQL

Using Relational Databases and SQL

Steven EmoryDepartment of Computer Science

California State University, Los Angeles

Lecture 1:Introduction to Relational Databases and

MySQL

Page 2: Using Relational Databases and SQL

Database Origin

Database comes from the open compound word “Data Base”

Data Base was a military term (circa 1964)Data Base implies data that is both persistent and shared (think Air Force Base)The military funded much of the research into the early electronic computers of the 40’s and 50’s because of World War II and the Korean War

Page 3: Using Relational Databases and SQL

What is a Database?

A structured collection of persistent data that is typically meant to be sharedUsed to model organizational activitiesStructure is defined through a database modelNo database model, no database!Examples:

Airlines, Banks, Stores and Universities

Page 4: Using Relational Databases and SQL

Database Models

The Two Levels of a Database ModelPhysical Level (how data is stored)

The things we don’t care about

Logical Level (how data is generalized)The things we do care about

The Basic ModelsHierarchical Model (IBM’s IMS)Network Model (CODASYL)Relational Model (ALPHA, SEQUEL)

Page 5: Using Relational Databases and SQL

Physical/Logical Separation

Previous to the relational model, one had to write a program that traversed pointers at the physical level to extract data from a database (think like programming in assembly language)By abstracting the physical level and writing a program at the logical level instead (think like programming in Java), extracting data from a database became easierFirst proposed by Dr. Edgar Frank Codd.

Page 6: Using Relational Databases and SQL

Dr. Edgar F(rank) Codd

MA Mathematics, MA ChemistryMS and PhD in Communication SciencesACM Turing Award (1981)

Page 7: Using Relational Databases and SQL

Relational Model

Proposed by Edgar F. Codd (circa 1969)Database is a collection of tables (relations)Relational comes from ‘Relational Algebra/Calculus’ and not from ‘Relationships’Relational model is very mathematicalDominant database model

Thanks to Larry Ellison, founder of Oracle, who was first to aggressively market a commercial relational database product (Ellison is currently the 4th richest person in the world)

Page 8: Using Relational Databases and SQL

TablesArtists = Table (Relation)ArtistID, City, Region, ... = Columns (Attributes)Each row is called a Record (Tuple)

Page 9: Using Relational Databases and SQL

Data Types

Determines storage requirementsCommon attribute types

StringNumeric (float, double, real)Date and TimeBlobs and Clobs (images and other binary data)

Page 10: Using Relational Databases and SQL

Database Schemas

The definition of the database, where you defineThe name of the databaseTables

Column names, types, and constraints

Relationships between tablesStored functions and procedures

Schemas are typically represented by a schema diagram

Page 11: Using Relational Databases and SQL

Database Schemas

Page 12: Using Relational Databases and SQL

Database Management Systems (DBMS)

Software (programs) to manage databasesCreation/DeletionMaintenance (inserting, updating, and deleting records)Security (encryption, user access control)

Common DBMSsMySQL, PostreSQL (open source)Oracle, DB2, MS SQL Server (commercial)

Page 13: Using Relational Databases and SQL

Database Management Systems (DBMS)

You can have multiple databases, each with a single schema

A separate database for each applicationToystore (First database)Bookstore (Second database)Furniture Store (Third database)Etc.

You can also have a single database, with multiple schemas

Page 14: Using Relational Databases and SQL

DBMS Diagram

Page 15: Using Relational Databases and SQL

Query Languages

Query Language = A language used to extract data from a databaseDomain-Specific Language

Only for databases

HistoryCodd, Alpha (1971)Chamberlin and Boyce, SEQUEL (1974)

Eventually renamed to SQL

Page 16: Using Relational Databases and SQL

QL Examples

Alpha (Codd)

SEQUEL (Chamberlin, Boyce)

Page 17: Using Relational Databases and SQL

SQL

Stands for Structured Query LanguageA non-procedural, domain-specific language (not like C or C++)An open ANSI standardSupported by most major DBMSSome variations in implementationsUsed by programmers, managers, and database administrators

Page 18: Using Relational Databases and SQL

SQL Functions

View information from relational databasesSingle and multiple table selectionsCalculation and analysis

Manipulate information in relational databasesInsert and delete recordsUpdate records

Create relational databasesCreate databases, tables, constraints, ...

Page 19: Using Relational Databases and SQL

Other Interesting Facts

Question: Why is a database always represented by an aluminum can or some type of cylinder?

Page 20: Using Relational Databases and SQL

Other Interesting Facts

Answer: Because that’s what disk storage looked like back in the old days!

Page 21: Using Relational Databases and SQL

Other Interesting Facts

Since IBM already had a database product called IMS, which was currently being used in the Apollo space program (1969 – 1972), Dr. Codd was asked by IBM not to disparage IMS nor promote his model over IMS since it might hurt sales of IMS.Many people to this day believe that hindered IBM and Dr. Codd from making all the money that Larry Ellison of Oracle has made.

Page 22: Using Relational Databases and SQL

Downloading MySQL

Go to CS122 Wiki page and under the Required Software section, click on the links to

MySQL (client and server program)MySQL GUI Tools (alternative client program)MySQL Workbench (schema utility)

Download the versions for Windows, without the installerExtract all three to a flash drive (preferably)

Page 23: Using Relational Databases and SQL

Important Notes!!!

You can put MySQL directly onto these computers, but be aware that other students may delete your stuff (by accident or otherwise)Do not leave homework, labs, or programs on our computers as other students may find and mishandle your stuffAlways back up your work onto a personal flash drive before you leaveDon’t forget your flash drives


Recommended