Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Databases & SQL

Similar presentations


Presentation on theme: "Introduction to Databases & SQL"— Presentation transcript:

1 Introduction to Databases & SQL
1.0 – 1/28/10 CSC 150 Database Applications & Designs using SQL Covers material in Chapter 1

2 What is a Database? A collection of logically related computer data organized for rapid search and retrieval of information We must define our terms 2 hour talk, spend 1 hour defining your terms

3 Where can databases be found?
Ideas?

4 Databases are ubiquitous

5 What is a Relational Database?
Developed by E. F. Codd in 1970 A collection of tables Tables used to store data Tables are rows of records Records contain fields Tables can be related to other tables through common fields Can hold vast amounts of data Thought that it was impractical, couldn’t work on mainframes Name based on way structured Uses tables rather than flat files Other formats: Hierarchical (Yahoo) and Network – Not easy to change Tables like Excel spreadsheet – Is Excel a database? No, cannot query

6 Why use a Relational Database?
Flexibility Runs on many platforms Simplistic Easy to learn Supports many simultaneous users Can support a front end

7 What is a Table? Means of storing data in a relational database
Set of data elements stored in rows and columns Two dimensional structure

8 Student ID Last Name First Name Major Code 100100 Simpson Homer PT
100200 Flanders Ned EN 200100 Marjorie AC 400300 Szyslak Moe MX Typical RDB table Note first row is names of columns

9 Parts of a Table Rows Columns Cells Primary Key

10 Rows Records Data for one object, event, or relationship
All rows contain similar data Table may have 1,000s of rows Rows not in a predictable order Wouldn’t store student info & professor info in the same table

11 Columns Field Each column named Each column has one datatype
Some columns may allow for no data – null (unknown value), some may not Columns in specific position 2 or more, usually less than 40 Names must match in related tables Within a table, each column must have a unique name

12 Cell Where one row meets one column
Atomic – single, undividable piece of data – used as whole Many datatypes All cells in a column have same datatype All cells in a row contain data about one object, event, or relationship Atomic – splitting first and last name – got back to example table Most tables use only a small number of datatypes

13 Common Datatypes Text (Alphanumeric) Numeric
Character Word String (several words) Code (M/F, S/M/D) Numeric Integer Floating Point Currency Date/Time Null – no value/unknown value Text can be numbers not used for arithmetic operations – phone number – student id – many primary keys are number fields used as text

14 Primary Key Unique identification for each row
May be single column or more than one column Noun – Names the object, event, or relationship Other columns are adjectives Allows for quick access of table data Noun – names the object for each row, other columns are adjectives because the provide a description of the object

15 Rules for Primary Key No two rows can have the same primary key
Primary key cannot contain null values No table can have more than one primary key Go back to table – what if Last name was the primary key

16 What is the main reasons to store data in a database?
To reduce redundancy To maintain data integrity Redundancy – duplication, storing same information in more than one place A database allows data to be stored in the efficient means Less space taken up to store data – less chance for error Integrity – data stored in the database is correct

17 Normalization Used during database design
A step-by-step process used to reduce redundancy Each step called a “Form” First Normal Form Second Normal Form Third Normal Form The higher the Form, the lower the data redundancy Data referred as being in 1st Normal Form, 2nd Normal Form & so on. Goal is to get data to third normal form

18 What do We Want to do to Data?
View the data Add new data Update existing data Delete obsolete data Query the data Jobs a database needs to perform Need tool program to help - SQL

19 What is SQL? “Structured Query Language”
Developed at IBM in the early 1970’s by Donald Chamberlin and Raymond Boyce Used to query & manage a relational database Declarative language What, not How English like Basics are easy to learn Procedural language – we tell computer how to do something Declarative language – we tell the computer what we want, & it figures out how to do it

20 Access & Oracle Two of the most prominent database programs
Both use SQL Both used in textbook Access does also have a visual query method Some slight differences in environment – justifications, etc Oracle – more serious, used by larger businesses


Download ppt "Introduction to Databases & SQL"

Similar presentations


Ads by Google