Create Database Objects Database is a collection of data related to particular subject or purpose. Within a data base, information about a particular entity (object), such as employee or order (arrangement of items), is categorized in to tables, records, and fields. Microsoft Access It is a data base program that is used to design Tables, Queries, Forms, and Reports.
ITSS2, Jimma TVET College
Cont’d Relational Database: in relational databases such as Access, data is stored in tables made up of one or more fields (Access calls a column a field). The data stored in each column must be of a single data type such as Character, Number or Date. A collection of values from each column of a table is called a record or a row in the table.
ITSS2, Jimma TVET College
Designing Database Good data base design ensures that your data base is easy to maintain. You store data in tables and each table contains data about only one subject, such as customer, Employee and other records. Therefore, you update a particular piece of data, such as an address, in just one place and that change automatically appears throughout the data base.
ITSS2, Jimma TVET College
Basic steps designing database Determine the purpose of the data base: for which company are you going to design the data base, for school, super markets, Hospitals… Determine the Field you need for the data base: Each field is a fact about a particular subject. For example you might need to store the following facts about your students: - ID card, first name, middle name, last name, Age, Sex, Address, City, and phone. Determine the tables you need for the data base. For example, if you have a Hire Date field, its subject is an employee, so it belongs in employees table.
ITSS2, Jimma TVET College
Cont’d Identify the field or fields with unique value in each record: In order to connect two or more tables you need to have a field(s) that uniquely identifies individual records in the table. Such a field or set of fields is called a primary key. Determine the relationship b/n tables: In order to use fields from different tables, you need to connect two or more tables.
ITSS2, Jimma TVET College
Database Objects Tables Tables are where the actual data is defined, entered and store a database’s data. Tables consist of records (rows) and fields (columns). Queries Queries ask a question of data stored in a table. A query consists of specifications indicating which fields, records, and summaries you want to see from a database. Forms Forms are custom screens that provide an easy way to enter and view data in a table or query. Reports Reports present data from a table or query in a printed format. ITSS2, Jimma TVET College Table Tables are the main units of data storage in a database. A table is a collection of data about a specific topic; it is made up of one of more fields. Field: a field is a column in a table and defines a data type for a set of values in a table. For example, a mailing list table might include fields for first name, last name, address, city, state, zip code, and telephone number. Record: a record in a row in a table and is a set of values defined by fields. In a mailing list table, each record would contain the data for one person as specified by the intersecting fields.
ITSS2, Jimma TVET College
Cont’d Data type: data types are the properties of each field. A field only has one data type, such as Character, Number or Date. Primary Key :a primary key is a value that can be used to identify a unique record in a table. Design View: it provides the tools for creating fields in a table. Datasheet View: it allows you to update, edit, and delete information from a table.
ITSS2, Jimma TVET College
Elements of table with design view
1. Field Name – The name by which the field is
identified. 2. Data Type – When you add a field MS-Access automatically assigns in the text. If you want to change this data type, you can select from data type list. 3. Description – Is an optional descriptive text that you can add for created fields.
ITSS2, Jimma TVET College
Data Types 1. Text – Used to store text information (Alphanumeric character) up to 255 bytes. 2. Memo – Used to store large block of text up to 64,000 characters (About 20 pages) in length. 3. Number – Used to store numeric data that can be used in mathematical calculation. 4. Date/Time – Used to store date and time. 5. Currency – Used to store monetary values. 6. Attachment_ You can attach images, spreadsheet files, documents, charts, and other types of supported files to the records in your database ITSS2, Jimma TVET College Cont’d 7. Auto number – To store numeric values (sequential value) that MS-Access automatically increment the value by 1 starting from 1. 8. Yes/No – Used to recording logical Yes/NO, True/False, and On/Off values. 9. OLE object – Used to store Graphics, Drawing, Photographs, Signature and other objects that were created in other application. 10. Lookup Wizard – Used to create a field that allow you to choose a value from a list of values using combo box (List box).TVET College ITSS2, Jimma Setting Field Properties Field properties are a set of characteristics that provide additional control over how a field works. The available field properties in Ms-Access are; 1. Field Size – Sets the maximum allowable number of characters stored in a field. The default field size for Text data type is 50. 2. Format – Affect how a field data is displayed. You can use predefined format or set your own. Examples Date Format Predefined Format Sample Format - Short date 19/6/1998 - D/M/YYYY - ITSS2, Jimma TVET College Cont’d 3. Input Mask – Display formatting characters in a field. You can use predefined masks or customize your own. Cause character to the right to be converted to upper case. E.g. >????? = ABEBE >?<???? = Abebe 4. Caption – Used to describe a field name on table datasheet view. E.g. Fname = First Name Lname = Last Name 5. Default Value – a value that is automatically entered in a field when records are created. 6. Validation Rule – An expression used by MS-Access to determine whether or not an item entered in a field should be stored as value. ITSS2, Jimma TVET College E.g. F or M =To enter either F or M. >20 = To enter a value grater than 20. 7. Validation Text – A text that appears when invalid data is entered in a field. When you enter a data that break the validation rule, a validation text will be displayed as message. 8. Required – Setting the forces a user to make an entry in a field. If this field property is set to Yes MS-Access doesn’t allow a null value to be stored in this field. ITSS2, Jimma TVET College Setting The Primary Key
Setting The Primary Key
To set a primary key; - Switch to table design view - Select the field that you want to define as a primary key - Click on Edit menu – Select Primary key command For example, a Customer ID field in the Customers table might also appear in the Orders table. In the Customers table, it is the primary key. In the Orders table it is called a foreign key. A foreign key, simply stated, is another table's primary key.
ITSS2, Jimma TVET College
Types of database Relationships
1. One-to-One Relationships
2. One-to-Many Relationships
3. Many-to-Many Relationships
ITSS2, Jimma TVET College
One-to-One Relationships In a one-to-one relationship, a row in table A can have no more than one matching row in table B, and vice versa. A one-to-one relationship is created if both of the related columns are primary keys or have unique constraints. The primary key and foreign key side of a one-to-one relationship is denoted by a symbol. Example: Husband and Wife
ITSS2, Jimma TVET College
One-to-Many Relationships A one-to-many relationship is the most common type of relationship. In this type of relationship, a row in table A can have many matching rows in table B, but a row in table B can have only one matching row in table A. The primary key side of a one-to-many relationship is denoted by a key symbol. The foreign key side of a relationship is denoted by an infinity symbol. Example: Mother and Child
ITSS2, Jimma TVET College
Many-to-Many Relationships In a many-to-many relationship, a row in table A can have many matching rows in table B, and vice versa. You create such a relationship by defining a third table, called a junction table, whose primary key consists of the foreign keys from both table A and table B. Examples Trainee, Competency and Takes
ITSS2, Jimma TVET College
Referential Integrity Referential Integrity is a system of rules that Microsoft Access uses to ensure that relationships between records in related tables are valid and that you don't accidentally delete or incorrectly change related data.