170 likes | 326 Views
CPSC 203 Introduction to Computers. T59 & T64 By Jie (Jeff) Gao. Introduction to Database. What is a database? A database is a collection of information related to a particular subject or purpose. Why should we use databases? Keep consistent information altogether
E N D
CPSC 203Introduction to Computers T59 & T64 By Jie (Jeff) Gao
Introduction to Database • What is a database? • A database is a collection of information related to a particular subject or purpose. • Why should we use databases? • Keep consistent information altogether • Easy to manage and find useful information • Easy to manage related information CPSC 203 Tutorial by Jie Gao
An Example CPSC 203 Tutorial by Jie Gao
Terminology (1) Field Table Record CPSC 203 Tutorial by Jie Gao
Terminology (2) • DBMS • Database Management System • Database Objects in Access • Table • Query • Form • Report • Pages …… CPSC 203 Tutorial by Jie Gao
Create a Database • In Access, all tables and objects are stored in a single database file • You need to specify a (new) database file when starting Access • All data is saved automatically in the database file • Be careful when you work with database files on the WebDisk (see details on my website) CPSC 203 Tutorial by Jie Gao
Creating A Table • Work in Table Design View • Decide what fields to add (columns of the table) • Field name should tell you something about the field content • Select appropriate data type for fields • Optionally: • Required? • Field size • Set primary key • Give the table a name CPSC 203 Tutorial by Jie Gao
Data Types • Define what is expected in a field • Inputs will be checked against the data type • Available types: • Text, Memo • Number • Date/time • Currency • Yes/No • … CPSC 203 Tutorial by Jie Gao
Primary Key • The primary key is a field (or combination of fields) in a table • Values in the primary key should be present and unique in all rows • Primary key is used to index and identify each row quickly • Use the “key” tool button to specify primary key CPSC 203 Tutorial by Jie Gao
Alter A Table • Change in design view • Everything could be changed • If delete a field, the data in that field will be deleted CPSC 203 Tutorial by Jie Gao
Edit Data • Input data in datasheet view • Move your cursor to different records using the navigator at the bottom of the datasheet view • Use Tab or Shift+Tab keys to move your cursor to the next or previous field CPSC 203 Tutorial by Jie Gao
A Little More Work • Sort • By a field • Ascending or descending • Data in a table is automatically saved; the layout of a table’s data view should be saved manually CPSC 203 Tutorial by Jie Gao
Forms in Access • A form in Access is used to provide a friendly interface to the user • With labels and input boxes to input and/or view data • The user can input data into a table through a form created on that table • The user can also navigate data by using the form CPSC 203 Tutorial by Jie Gao
Create a Form • Two methods: Wizard or Design View • Form Wizard is easy to use. You can create a form for a table with simple steps • Design View can provide you more power. You can implement advanced features! CPSC 203 Tutorial by Jie Gao
Form Wizard • Select • Which fields will appear in the formYou can select fields from multiple tables • Form type (layout) • Style • Name • You can click “Finish” when you accept the defaults for the following steps. CPSC 203 Tutorial by Jie Gao
Form Design View • You can • Add controls to the form • Drag fields into the form • Adjust the form layout • Add header or footer • Even do something like programming CPSC 203 Tutorial by Jie Gao
Assignment 3 • Start with a blank database • Create a table • Create a form on that table • Input data • Create reports • Create queries when necessary • Refer to the information on my web site CPSC 203 Tutorial by Jie Gao