Application Software: Databases
CHAPTERS 15-16
Databases
A database is a collection of dataDatabase software helps you find, organize,
update, and report information stored in a database
Database Concepts Database Management System Software is
used to create, maintain, and access information in an electronic database.
Common Database Management SystemsMicrosoft AccessBorland dBasemySQLOracle
Data Organization “Hierarchy”
Databases: a collection of files with the connections between them
Files : Information dealing with different types of data are stored in different files
(i.e. addresses, transcripts, and schedules)Records : Each instance in a file is called a record
(i.e. all information about one student)Fields : Each part of a record is called a field
(i.e. Zip Code for a student)
6
Database Terminology Field Record Table Database
A database is made up of one or more tables
Individual tables in a database
Records
Individual fields
Tables in a Database
Each DB file has a table structure for its records.
The table structure is created first and given a table name as well as a set of fields.
Table Design Considerations
Just as you first create a blueprint to build a house, you should first sketch or outline the design of a database table
Careful pre-planning
will save you much time
in the future
Tables in a Database Each Field in the table has…
namedata type field width
After the table structure is complete, data can be entered into the table’s fields.
default valuesrequired?primary key?
Data Types for the Fields
Text alphanumeric, alpha, string – holds any character
Numeric byte, short, long, integer floating point (decimal) , currencies
Date Memo Logical (binary or boolean or yes/no) Hyperlink Object
Table Design Considerations – Field Size Property
Set the field size in Table Design View Always anticipate the current field size,
may one day need to be larger
Set field size in the Field Properties grid of Table Design View
Data Validation
Make sure the data in the computer matches the real-world information it representsData Type EnforcementDefault ValuesRangesRequired FieldsUnique KeysNon-Null Keys
Data Validation
Make a field numeric types ONLY when you plan to do arithmetic with the field and it makes sense to do it!
Social security numbers, for example, should be TEXT not Long integers – you do not want someone to total them by accident, it would be meaningless
Table Design Consideration – Sarbanes Oxley Act (SOX)
Protects the general public and companies shareholders against fraudulent practices and accounting errors. Requires that all business records be saved
for a period of five years and be made available to the SEC upon request
SOX RECORDS
Do Not
Discard
Table Design Considerations - PNPI
Short for Personal, Non-Public, Information PNPI laws govern the safeguarding of data such as:
social security numbers credit card numbers Educational records (FERPA) bank account numbers medical records (HPAA)
Table Design Considerations – Store Data in its Smallest part
For greater flexibility, store data in its smallest part Instead of one field for an address, use many Instead of one field for a name, two or three
Like this
Not like this
Table Design Consideration - Plan for Date Arithmetic
Using a data type of date/time for all date fields allows the use of date arithmetic
Fields declared as a data type of Date/Time
19
Work with Table Views
Datasheet (Table) View – used to add, modify, delete and view records
Design View – used to create and modify the fields in a table
Datasheet View
Design View
Work with Properties
Field Properties can be used to specify characteristics for individual fields
Located in the lower pane of Table Design View
Caption property
Field Size property
21
Objects
Tables Queries Reports Forms Macros Modules
Objects
Reports
Reports are created when a more formal printout is desired. Use a wizard to create a reportExecutes one or more queries and presents
the results in a more organized fashionCan sort the data, can do simple arithmetic
(totals)
Queries Queries are questions used to retrieve
information from a database. Contain criteria to specify the records and
fields to be included in the query results. Can contain wild cards or logical operators to
make more complex queries * and ? <, >, <=, >=, <>, =, AND, OR, etc…
Named and saved so they can be run again at a later time.
Query Languages A query language such as SQL (Structured
Query Language) provides a set of commands for locating and manipulating dataLIST ALL FOR STATE = “KY”Not user friendly
Query By Example is another query language Fill out a form that describes your queryMore friendly
Queries
Queries allow us to ask questions about data This record set that answers our question is called
a dataset
Employees table
Dataset resulting from querying table for only employees who are Sales Representatives
Using Query Design View
Query Design grid has two panes – the table pane and the design pane
Striking the F6 key will toggle you between sections
Tables pane
Design pane
Specifying Criteria in a Select Query
Field row – displays the field name Sort row – enables you to sort the dataset Show row – controls whether or not you see a
field in the dataset Criteria row – determines the records that will be
selected for display
Fields in design grid allow us to specify criteria for the dataset
Specifying Criteria – Currency and Operands
Specify criteria with currency Without the dollar sign With or without the decimal point
Use operands such as: Less than and greater than Equal to or not equal to
Greater than (>) operand
Currency amount entered without dollar sign
Specifying Criteria – Wildcards
Asterisk - searches for a pattern that includes any number of characters in the position of the asterisk
Question mark - searches for a pattern that includes a single character in the position of the question mark
Query with asterisk wildcard and resulting dataset
Query with question mark and asterisk wildcard and resulting dataset to specify criteria for the dataset
Specifying Criteria – And and Or
OR finds records that can match one or more conditions
AND finds records that must match all criteria specified
Or Criterion and resulting dataset
And criterion and resulting dataset
Run a Query
Running, or executing, a query is done by clicking the Run command
Run command
Add a Total Row in a Query
The total row can be added to the design grid by clicking the Totals Icon
Totals Icon
Total row added to the query
Calculated Queries
Will find averages, max, min, sum, std Work with ONE field – NOT more! Add Totals row to query Open “Group By” menu Choose appropriate function Run query
Sorting Records
Can sort records in a database by field values Single Field Sort
Sort all students in the DB by home state Multi-Field Sort (Field A within Field B)
Sort all students in the DB by home state then by alphabetical order of last name (Name within State) State is primary sort field, Name is secondary sort field
Access sorts multiple fields left to right
35
Sorting Table Data
Lists records in ascending or descending order according to one or more fields
Last Name field sorted ascending
Last Name field sorted descending
Concurrent Processing Large databases allow more than one person to
access a file at one time Have to be careful to control access - can lose data
that way - who writes LAST? MS Access uses a .ldb file to control this .ldb file created when a mdb file is opened, says that it
is "locked" so no one else can use it .ldb file goes away when mdb file is closed DO NOT submit it INSTEAD of your mdb!
37
Compact and Repair
Compact and Repair is located under the Manage menu
Fixes problems due to inefficient file storage and growth of a database Should be performed everyday Often decreases the file size by 50% or more
38
Access or Excel?
You are working with large amounts of data
You need to create relationships between your data
Your data is of a manageable data size
There is no need for relationships between data
You are primarily creating calculations and statistics
Use Access when: Use Excel when:
Understand Large Database Differences Most large companies separate their
database into front and back ends Front end – contains the objects needed to
interact with data, but not the tables where the record values reside
Back end – contains the tables where the data resides
Data Mining – a question for society
the process of extracting hidden patterns from data (from Wikipedia)
Businesses and governments do it all the time (finding prospects, detecting terrorism)
For Knowledge Discovery and Prediction Privacy concerns – identifying specific
individuals