You are on page 1of 71

COURSE OUTLINE

Instructor: Mr. VICTOR


Mode of deliver: 2 periods @ week
1.30 hrs @ each period

Examination: group assignment 10 marks


timely quiz 2@ 5marks
midterm exam-20 marks
final exam- 60 marks
References:

-http://www.studytonight.com (website)
-Database management system by third edition(3ed)
by Raghu Ramakrishnan (book)
COURSE OUTLINE
 Basic concept of database
 Purpose of database management system
 Database processing system over file systems
 Design simple database system using
Microsoft access
 Designing logical part of database using ER
diagram
Database management System
• A database is a collection of information that is organized so that it can
easily be accessed, managed, and updated. In one view, databases can be
classified according to types of content: bibliographic, full-text, numeric,
and images.
OR
A database is a collection of data, typically describing the activities of one or
more related organizations. For example, a university database might
contain information about the following:
• Entities such as students, faculty, courses, and classrooms.
• Relationships between entities, such as students' enrollment in courses,
faculty teaching courses, and the use of rooms for courses.
Database management System
A database management system, or DBMS, is software designed to assist in maintaining and
utilizing large collections of data. The need for such systems, as well as their use, is growing
rapidly. The alternative to using a DBMS is to store the data in files and write application-
specific code to manage it
or
Database Management System is a collection of interrelated data and set of programs to
access
those data. The DBMS is a general purpose software system that facilitates the process of
defining constructing and manipulating databases for various applications.
Examples of dbms
-microsoft access
-sql server 2005, 2007,….
- Xammp sever
BASIC CONCEPTS IN DATABASSE

Data
Data is a collection of raw information, it is unorganized data or facts and it has to be
processed. examples of data may be collection of words, numbers, graphics or sounds
Information
Information is a collection of processed data and arranged in some orders . Information has
proper meanings , it is through information we can make decision examples of data may
includes i.e. census report, election results, students examination results
Table
a table is a collection of data elements organized in terms of rows and columns.
A table is also considered as convenient representation of relations.
But a table can have duplicate tuples while a true relation cannot have duplicate tuples. Table
is the most simplest form of data storage. Below on next slide is an example of Employee
table
table
Record 
A single entry in a table is called a Record or Row. A Record in
a table represents set of related data. For example, the
above Employee table has 4 records. Following is an example
of single record.
Field
A table consists of several records(row), each record can be
broken into several smaller entities known as Fields.
The above Employee table consist of four fields, ID, Name, 
Age and Salary.
Column
In Relational table, a column is a set of value of a particular
type. The term Attribute is also used to represent a column.
For example, in Employee table, Name is a column that
represent names of employee
Database Keys

Keys are very important part of Relational database. They are used to establish and identify relation between
tables. They also ensure that each record within a table can be uniquely identified by combination of one or
more fields within a table

• Super Key
Super Key is defined as a set of attributes within a table that uniquely identifies each record within a table.
Super Key is a superset of Candidate key.

• Candidate Key
Candidate keys are defined as the set of fields from which primary key can be selected. It is an attribute or set
of attribute that can act as a primary key for a table to uniquely identify each record in that table.

• Primary Key
Primary key is a candidate key that is most appropriate to become main key of the table. It is a key that
uniquely identify each record in a table
• Foreign keys
A foreign key is a column or a group of columns that is a primary
key in another Table. Foreign key relates the rows of the Table
to other rows that appear elsewhere in another Table
Rules for Foreign keys
Value must refer to the existing primary key.

• Entities
An entity defines a thing that exists and is distinguishable from
which data will be collected. i.e. Person, place, object or
concept. Entities are basic building blocks of the database
design.
Entity
Attributes
Attributes describe properties of entities and relationships.
Examples attributes for an entity student includes; name, age,
registration number , program course, year of study…..

attribute
Important rules In creating tables
in data base
DESIGN SIMPLE DATABASE USING ACCESS……

• Introduction
A database is a collection of information that's related. Access
allows you to manage your information in one database file.
Within Access there are four major areas: Tables, Queries,
Forms and Reports
• Tables store your data in your database
• Queries ask questions about information stored in your tables
• Forms allow you to view data stored in your tables
• Reports allow you to print data based on queries/tables that
you have created
Example1. creating KITM database
• Entities:
-students
-tutors
-other employee

• Attributes
-student(Name, RegNum, Year_Of_Study, Program_Course,
Department)
-Tutor(Name, AdNum, Adm_Year, Department, Salary,
course_Teach )
- Other_Employee(name, IdNum, employee_type, Admin_Year)
Creating a KITMDB Database
Continue……..
Continue….
• To Switch to Design
view:
• 1) Click the View button
on the Home Ribbon
• 2) Type a name for the
table
• 3) Click OK
Common Microsoft Access Data Types
Continue…..
• To Enter Fields in a Table:
1) Type a name for the first field in the table
2) Press Enter
3) Select a data type
4) Press Enter
5) Type a description for the field
6) Press Enter
Continue this until all necessary fields have been
entered into the table.
Continue…..
• Note: The order that
you enter the field
names is the order the
fields will appear in the
table and on a form.

• To View the Datasheet:


Click the View button on
the Ribbon
Setting a Primary Key
• The Primary Key is the unique identifier for
each record in a table. Access will not allow
duplicate entries in a Primary Key field. By
default, Access sets the first field in the table
as the Primary Key field. Examples of primary
keys may include student registration number,
employee admission number, licenses reg
number and all others that can provide unique
identification of Entities
Continue…..
• To Set a Primary Key:
1) Switch to Design View
2) Position your cursor in the
field you wish to set as the
Primary Key
3) Click the Primary Key button
on the Ribbon

• To Switch Back to Datasheet


View to Enter your Records:
Click the View button on the
Ribbon.
Entering Data in a Table
• Once you have entered the fields and set the data
types it is now time to enter the records in a table.
• To Enter Data in a Table:
1) Make sure you are in Datasheet View
2) Enter the data into the table by pressing the tab
key to move from one cell to another
3) When you have completed the record (row),
press Enter
Continue…..

• Input Masks
An Input Mask is used to pre-format a field to “look/act” a certain way
when a user inputs data.
Example: You could create an input mask for a date when employee
was admitted at Kilimanjaro field that automatically inserts the
forward slash(/).
To Create an Input Mask for a Field
1) Open a table in Design View
2) Click in a field for which you’d like to create an input mask
3) In the Field Properties section at the bottom of the screen, click in
the Input Mask line and notice the Build button that appears at the
right end of the line (see below)
Continue……..
Multi-valued field
• In Access 2007 it is possible to create a field that holds multiple
values. This can be used to store a multiple valued selection from a
list of choices, but only when the list of choices is relatively small.
For example, from table tutor in field of COURSE_TEACH, you
can create a lookup list to enter that courses taught by given
individual Tutor. When the combo box is selected, you can select or
deselect check boxes to indicate your choices. The selections are then
stored in the multi-valued field, and are separated by commas when
displayed. In Access 2007, you can use the Lookup Wizard to create
a multi-valued field. The Lookup Wizard takes you through the steps
needed to create a lookup list. It automatically sets the appropriate
field properties and creates relationships where necessary.
Multi-valued field
1. Open the desired table in Design view, if necessary.
2. Type the desired field name in the next available row in the Field
Name column.
3. Click in the data type column next to the new field name.
4. Click the arrow and select Lookup Wizard.
5. Select the desired lookup source.
6. Enter the desired data into the column.
7. Enter the desired number of columns.
8. Select the box below the Col1 heading.
9. Enter the first desired lookup value.
10. Enter additional lookup values as desired.
11. Select .
12. Type the desired label for the lookup column.
13. Select Allow Multiple Values.
14. Select .
15. Select Save on the Quick Access Toolbar.
16. Select Datasheet View on the Status Bar.
17. Use the lookup list to enter the desired values
Sorting Records in a Table
• By sorting your records in a
table, you are easily able to
view/locate records in your
table.
• To Sort Records in a Table:
1) Position your cursor in the
field that you wish to sort by,
by clicking on any record in
that field.
2) Click either the Sort
Ascending or Sort
Descending icon
Reordering of the fields
• To move a field
1. -In navigation pane click the table
which you want to edit and then click design view
2.- Click the row selector of the field you
want to move, and then drag the selector of the
row to the location of your desire. A line appear
to show you exactly is in which location your
record is going to be placed. See in figure on next
page
Continueee………
Creating Relationships
• Tables can be joined, or related, in order to access and coordinate
information in all the fields of the related tables. Joining tables is a useful
way to avoid entering duplicate information in various, related tables. In
addition, it allows you to create reports, forms, and queries from the
related data tables and save them in the database file. Relating tables
allows you to create smaller, more efficient tables that can be referenced
when you need access to the data. When you relate tables, the table from
which you select a field to join is the primary table, and the second table
containing the field you want to associate is the related table. The tables
must have at least one common field that contains the same type of data.
This common field is called the join field. The join fields in both tables
must have the same or equivalent data types and, if they are Number
fields, they must have the same field size. In addition, the join field in the
primary table must be the primary key in order to avoid duplicate entries.
CONTINUE……….
• For example, the
following table consists of
customer names and
address fields, along with
a unique identification
number for each
customer, which serves as
the primary key in the
table. You can create this
number or allow Access to
create it for you.
CONTINUE………
• You could then create
separate table
consisting only of orders
placed by customers.
This table would also
contain the field for the
unique customer
identification number,
but not the customers’
names and addresses.
EXERCISE

CREATING RELATIONSHIPS
1. Open Relate1x.accdb.
2. Open the Relationships window.
3. Add the Client and Project tables to the Relationships window.
4. Create a relationship between the Client ID field in the Client table and the Client ID
field in the Project table; set referential integrity for the relationship.
5. Add the Trainer table to the Relationships window.
6. Create a relationship between the Trainer Initials field in the Project table and the
Initials field in the Trainer table; set referential integrity for the relationship.
7. Close the Relationships window and save the changes.
8. Open the Client table in Datasheet view and view the sub datasheet for the CONCORD
client. Then, collapse the sub datasheet and close the Client table.
9. Open the Relationships window. Delete the relationship line between the Project and
Trainer tables and remove the Trainer field list, since it is no longer related to any tables.
Then, close the Relationships window and save the changes.
QUERIES
• A query is a means of extracting information from tables. You can
use queries to analyze the data in a table or to extract data for a form
or report. Queries are commonly used to display data in related tables
and enable you to control not only which records to display, but also
which fields. For example, you may want to give a sales
representatives a list of the contacts and telephone numbers for a
particular region; you can create a query to extract just the contact
names and telephone numbers within the specified region.
• A query does not contain data; rather, it is a set of instructions.
Access uses these instructions to select and display the desired
records in a table. As a result, whenever new data is added to the
queried table, the query is automatically updated; if the new records
meet the conditions of the query, they will be included when the
query runs.
Continue………..
• The result of a query is called a recordset. A recordset can be
sorted, printed or filtered in the same manner as a table.
When you open or run a query, a recordset appears. A recordset
contains all the fields and records that meet the conditions of the
query. Although the recordset is not a table, it can be used to
edit or add new records in the queried tables.
The Simple Query Wizard guides you through the steps for
creating a basic select query. When you use the Simple Query
Wizard, you select the table you want to use and the fields you
want the query to display. Then, you name the query and choose
whether to display the results of the query (recordset) or go to
Design view to work with the query design.
Continue………..
Continue…………..
CREATING A QUERY IN DESIGN VIEW
• You can create a query in Design view. This option gives you the most
flexibility in designing a query. It allows you to add criteria for selecting
records, as well as sort the recordset. When you create a query in Design
view, the design grid is used to set up the query.
The field lists of all tables to be used in the query appear in the top pane.
The design grid appears in the bottom pane. You drag the fields you want
to use in the query to the design grid and then add the desired criteria and
sorts.
NOTE: You can also add a field to a query by clicking in any blank column
in the Field row, clicking the drop-down arrow, and then selecting the field
you want to add; or by dragging the field to the design grid. And also You
can add all the fields to the design grid by dragging the asterisk (*) at
the top of the field list to the Field row in any column.
Continue………
SORTING A QUERY
• When you run a query, the records in the recordset appear in
the same order in which they appear in the design grid. You
can either sort the recordset or assign a sort order in the query
design. You can sort a recordset just as you would sort a table;
however, you would have to perform the sort every time you
run the query. If you assign a sort order in the query design,
Access will sort the recordset automatically each time you run
the query.
Continue…………..
Continue………….
CREATING BASIC FORMS
A form is a database object that is used to enter or display data
in a database. However, they can also be used to present data
in a more attractive format. Forms are usually designed to
display all the fields for a single record within the form
window, eliminating the need to scroll. You can also display
data from related tables in one form. .

• Note: The form feeds the table. If you edit a record on the
form, or create a record, that data will be passed to the table
it is associated with.
STEPS FOR CREATING FORM
1) Navigate to the table you want to base the
form on
2) Click Create on the Ribbon
3) Click Forms
To Enter a Record on the Form:
1) Click the View button on the Ribbon to
switch from Layout View to Form View
2) Enter the data for each field in the record,
pressing the Enter key to move to the next
field
3) Press Enter after you have entered data for
the last field
This will send the record to the table.
USING THE CALENDAR FOR DATE PICKING

• In Access 2007, fields and


controls that employ the
Date/Time data type have
new support - a built-in
interactive calendar for
choosing dates. This new
function simplifies the
date-picking process.
USING THE FORM WIZARD
• You can use the Form Wizard to quickly and easily
create a form. The Form Wizard guides you through
the process. First, you must choose the table or
query on which you want to base the form, and then
you can select the fields you want to include. Next,
you select the desired type of form layout:
columnar, tabular, datasheet,justified, PivotTable, or
PivotChart. You can then select a style from a
variety of predefined styles provided by Access.
Finally, you must name the form.
NOTE: If you base a form on multiple tables, the tables must all
be related. In addition, the Form Wizard will prompt you to
select how you want to group the fields on the form.
Procedures
CREATING BASIC REPORTS
• A report will allow you to print data based on queries/tables that
you have created Although you can print records from a table or
form, a report provides more precise control over the final
output. Reports can include page headers and footers, calculated
totals and subtotals, and even graphics. In addition, reports can
be used for invoices, orders, presentations, and mailing labels.
There are two basic types of reports: columnar and tabular. In a
columnar report, the field names are listed on the left side of the
page, and the field values are listed on the right. If space on the
page permits, there can be more than one column. In a tabular
report, the field names are listed across the top of the report,
and the field values appear in the corresponding columns.
NOTE
-Reports can include data from a single table or
related tables. Reports can also be based on
queries.
-You cannot edit data in a report.
Continues………….
• You can use the Report button to create a report quickly.
Auto Report automatically creates a simple columnar or
tabular report from the selected table or the query
without displaying any dialog boxes or needing any
input. You must, however, first select the table or query.
All fields in the table or query will appear in the report,
and the report title will be the same as the table or
query name. When using the Report button to create a
report, Access does not automatically save it; the first
time you close the report, Access prompts you to save it.
Continues………….
NOTE
The Report button creates the report using the
most recently used report settings. You can
switch to Design view to change the
formatting of an existing report.
Entity Relationship Diagram
• ER-Diagram is a visual representation of data
that describes how data is related to each
other.
Symbols and Notations
Components of E-R Diagram

1. Entity
An Entity can be any object, place, person or class. In E-R
Diagram, an entity is represented using rectangles.
Consider an example of an Organization.
Employee, Manager, Department, Product and many more
can be taken as entities from an Organization
Continue………..
2) Attribute
An Attribute describes a property or characteristic of an
entity. For example, Name, Age, Address etc can be
attributes of a Student. An attribute is represented using
eclipse
Continue………..
• Key Attribute
Key attribute represents the main characteristic of an Entity.
It is used to represent Primary key. Ellipse with underlying
lines represent Key Attribute.
Continue………
Composite Attribute
An attribute can also have their own attributes.
These attributes are known as Composite attribute
Continue………
3) Relationship A Relationship describes relations
between entities. Relationship is represented using
diamonds
Types of relationship
. Binary Relationship
. Recursive Relationship
. Ternary Relationship
Binary Relationship

• Binary Relationship means relation between


two Entities. This is further divided into three
types.
i. One to one binary relation(1:1)
ii. One to many binary relation(1:M)
iii. Many to one binary relation (M:1)
iv. Many to many binary relation (M:M)
One to one binary relation(1:1)

• This type of relationship is rarely seen in real


world

• The above example describes that one student can


enroll only for one course and a course will also have
only one Student. This is not what you will usually see
in relationship.
One to Many
•  It reflects business rule that one entity is associated with
many number of same entity. The example for this relation
might sound a little weird, but this means that one student
can enroll to many courses, but one course will have one
Student.

You might also like