CS 150 Computer Literacy

Databases

                                             
                                             

 

Databases are:

Large
Persistent
Integrated Collection of
Dynamic Data
with operations to update and manipulate data

They are used to store data instead of flat files because the access time is less. They are essentially a collection of tables filled with data. They are relational - the data in one table is related to data in another table.

Primary Keys - each table needs to have a primary key. This is a unique identifier for each entry (row) of the table. Usually you just use a number. Your student number is a primary key for you.

Foreign keys - they are the glue that binds database tables together. They show how data is related.

Example:

 

Table : person

ID # Name State
001 Jane VT
002 John CA
003 dave VT
     

Table : orders

Sale ID Customer ID Product ID Qty
602 001 105 2
603 001 107 1
       
       

Table: Products

Product ID Name Price Qty
105 Dog Food 18 8
106 Gold Fish 1 100
107 Leash 10 6
       

 

The Primary key of table person is ID#.

The Primary key of table orders is Sale ID.

The Primary key of table products is Product ID.

Table order has two foreign keys. One is from the Customer id field to the ID# in the people table. The other is from the Product ID field to the Product ID field in products. These are how the table relate. If I have a sales order, I can find all the customer information and all the product information.

SQL - structured query language

It's the language used to create, update, and modify a database.

To find out which customers live in Vermont we could write a query:

SELECT name, state
FROM person
WHERE state = "VT"

These are the most common SQL functions. There are others.

 

Access

Microsoft has built a database that is easier to use. It has a graphical interface so you don't have to learn SQL. But you do need to know about primary keys and relationships (foreign keys)

I will be going over how to create tables, forms, queries, reports, and pages in class.