0% found this document useful (0 votes)
2 views

6database Management

This document provides a comprehensive overview of database management systems (DBMS) in relation to the CSEC Information Technology syllabus for 2021. It covers key concepts such as the structure of databases, types of keys, data types, and the process of creating and manipulating databases using forms. Additionally, it outlines the advantages and disadvantages of relational databases, as well as terminology associated with database design and management.

Uploaded by

eloiserivers15
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

6database Management

This document provides a comprehensive overview of database management systems (DBMS) in relation to the CSEC Information Technology syllabus for 2021. It covers key concepts such as the structure of databases, types of keys, data types, and the process of creating and manipulating databases using forms. Additionally, it outlines the advantages and disadvantages of relational databases, as well as terminology associated with database design and management.

Uploaded by

eloiserivers15
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Database

Mana
gemen
t 2
Ms D
B
r
0
o
w
n
e
2
1
E
This booklet contains notes related to The
Fundamentals of Hardware and
Software. The notes follow the CSEC
syllabus for the 2021 Information
Technology exam.

CSEC IT Class
June 2021 Sitting
1-869-661-2282
[email protected]
Upon completion of this section, students should develop expertise in the design of a
database management system in the development of computer applications.

1. Explain the concept of database

A Database Management system (DBMS) – programs and database files that


allow timely and easy controlled access to data by a number of users.

A database is a collection of data files that may be used by a number of


applications with storage and access to the data controlled by a set of programs
known as Database Management System. The DBMS allows you to:
 Create and manage tables
 Perform queries on data and create additional ones as the need arises
 Enforce the integrity of the data
 View reports on the data and create new ones as the need arises

Relational database – a database that contains more than one table with tables
sharing data among them.

Advantages
 The information can be retrieved faster in ad hoc situations using queries
 You can design and create your own queries with minimal knowledge of
your database
 There are reduced updating errors and increased consistency as data is in
a standardized form
 Data duplication
 Data entry, storage and retrieval costs are reduced
 Security of data is increased
 You are able to present multiple views of data using report features

Disadvantages
 They are more time-consuming to design than a manual database
 Initial training is required
 Suitable hardware and software are needed to run the program
 They can be expensive to buy and maintain
2. Use terminology commonly associated with a database
Table – A collection of records, made of a set of rows and column. The
information you enter into the database will be stored in a table. In relational
databases, tables are also known as relations.

Entity – an item in the real world that is represented in a database.

Tuple – The details about a particular entity are called a tuple. A tuple is
represented by a record in a database.

Attribute – The individual properties of an entity are called its attributes. An


attribute is represented by a field in a database.

Row (tuple, record) – a collection of related fields. It contains a single row and
many columns. In relational databases, records are also known as tuples.

Column (attribute, field) – A single column in a table that stores data. It is


sometimes referred to as a field or an attribute.

Use of identifying keys


There must be some way to distinguish each record from all the other records in
the database. Fields such as ‘Name’ or ‘Date of birth’ are not always unique.
For example, a school might have more than one student with the same name.
For this reason, it is necessary to have a key Field which is different for every
record in the database.

Primary key – Most database tables include a Primary Key field which stores a
unique value. The Primary Key is often a code number which identifies each
entity in the database. In a school, students might have a ‘student number’
which appears on a school card that they carry. The Primary Key is usually the
first field in the table.

Alternate key – Any are other field that is unique and can be used as a primary
key.
Candidate key – A field (or group of fields) that has the properties needed to be
a primary key. Only one candidate key will become the primary key. They
candidate keys that were not chosen are called secondary keys or alternate keys.

Composite key – a primary key or candidate key that contains two or more
fields

Course Semester Year Professor Room


CISC 121 Fall 2009 Lamb WLH 205
CISC 121 Winter 2010 McCollam WLH 210
CISC 121 Fall 2010 Dawes WLH 205
CISC 124 Fall 2009 McCollam GOO 510
CISC 124 Winter 2010 Lamb GOO 510

Foreign key – A field in a table that matches the primary key of another table.
Data type or field type
The data or field type determines the type of data that a field can store.
Data Type Purpose
Text Used to store alphanumeric characters (letters or numbers)
up to 255 characters.
Number Used to store numbers with or without decimal places.
Currency Used to store money values
Date/Time Used to store date/time type values
Autonumber Creates automatic numbers, such as an ID Number
Memo Used to store blocks of text like notes up to 65536
characters long
Yes/No Used for storing a yes or no value

3. Create a database
Before you create a table in your database, it would be wise if you plan what
you want it to contain. You need to think about the field names, field types and
field sizes. Such a plan is called the table structure.

Datasheet View
Datasheet View displays the table as a grid. The fields are displayed as columns,
and the records are displayed as rows. The field names are listed as the column
headers. Datasheet View displays the data. If this table had data, it would be
displayed in the cells. Each row represents a record. If the table had say, five
records, there would be five rows of data. If you want to find out a field's data
type, you need to select that field, then select the Fields tab on the Ribbon. The
field's data type and other properties will be listed on the right side of the
Ribbon.

Creating a table in design view allows you to create the table with your choice
of field names, descriptions and field sizes.

Design View
Design View doesn't display any data. Therefore, there's more space available to
display other settings. The fields are listed vertically. They are listed above and
below each other as opposed to side-by-side. You can see the data type listed
next to each field. When you click on a field (in the top frame), the bottom
frame displays the properties for that field. You can then change these
properties as required.

The first thing you have to do is to type in the field name in the next available
row. Although field names may be up to 64 characters, most are pretty short.
Having spaces in your field names is generally considered to be bad practice, so
instead of First Name, say FirstName.

Creating a table in design view


1. Click on the create tab
2. Click on table design from the ribbon
3. Add the fields to the table
4. Change the field type of the field properties (if required)
5. Save the table

Data type
When you first create a field, it is automatically set to type Text. If your field
isn’t going to be storing text, you should change this to the appropriate type of
data for your field. This is very important for two reasons:

i. This makes sure that the user isn’t allowed to enter the wrong type of
data. For instance, if you left an age field as type Text, nothing is
stopping the user from entering something like ‘ABC’ or ‘hello’ for the
age.

ii. The data type affects what you are able to do with the data. For
instance, if the type is Number or Currency you can perform calculations
with it.
Field size
If the data type is Text, this is the maximum number that can hold in the field.

If the data type is Number, choose:


 Long Integer if the numbers won’t contain decimal points
 Double if they will contain decimal points

Format
This controls the way the information is displayed in the Datasheet view

If the data type is date/time:


 Choose a format from the list
 Or type the yyyy/mm/dd (all lowercase) if you want a four-digit year
followed by a two-digit month, followed by a two-digit day.
If the data type is Number:
 Choose fixed if you want a fixed number of decimal places
 Choose percentage if the number is a percentage

Decimal places
A data type is Number or Currency, choose the maximum number of decimal
places to be displayed or leave it as Auto if you want the computer to decide for
you.

Additional field properties

Description
Each field can have a description other than the field name or the caption. The
description can be used to provide information about the field. It can be a
maximum of 255 characters and is displayed on the status bar of a form when
the field is selected.
Field properties
Each field has a number of properties, which are displayed when the field data
type is selected. The properties include the following:

 Field size – this is the maximum number of characters that can be


entered in a field. For a text field, the default number is 255. You may
set it to size that best suits the data to be entered in this field. For
example, if the longest name to be entered is 25 characters, you should
set the size to 25.

 Format – the format property can be used to create custom formats that
change the way numbers, dates, times, and text display and print.
Format properties do not change the way the data is stored, only how it
is displayed. To change the format of a field, different symbols are
entered in a Format text box. Text and Memo data types can use any of
four symbols, as shown in the table below.

Symbol Description Example


@ A required text @@@-@@-@@@@ would
character or space display 246123457 as 246-12-
3457. Nine characters or
spaces are required
> Forces all characters > Would display SMITH
to uppercase whether you entered SMITH,
smith or Smith
< Forces all characters < would display smith whether
to lowercase you entered SMITH, smith or
Smith
& An optional text @@-@@& would display
character 12345 as 12-345 and 12.34 as
12-34. Four out of five
characters are required and a
fifth is optional
Input mask
An input mask is a pattern that controls the data that can be entered in a
field. It consists of literal characters, which are displayed in the field,
and mask characters, which are not. Literal characters are characters
such as the parentheses surrounding the area code of a telephone
number, or a hyphen used to separate the parts of a telephone number.
Mask characters are symbols that control where the data is entered in the
field, the type of data that can be entered, whether the data is required or
optional, and the number of characters.

Character What character is Entry required


accepted/its function
0 Digit yes
9 Digit or space no
# Digit, space, + , - no
L Letter yes
? Letter Optional
A Letter or digit yes
A Letter or digit optional
& Any character or space yes
C Any character or space optional
< Converts characters to
lower case
> Converts characters to
upper case
! Displays from left to right
\ Displays the next
character

Using a space between two quotation marks can create an empty space.
An example of the input mask for a telephone number is \(999”) “999\-
9999

Caption
The caption is the label for the field that is displayed on a form. If you
do not type in a caption, the default label will be the name of the field.
Enter the captions in initial caps and this has a tendency to present less
eye strain than all caps.

Default value
Default value is used to specify a value that is automatically entered in a
field when a new record is created. This property is commonly used
when most or all of the entries in a field will be the same. That default
value is then displayed automatically in the field. When a record is
added to the table, the user can either accept this value or enter another
value. This saves time when entering data. Character default values are
enclosed by quotation marks (“ “) and date default values sign (#).

Validation rule
When entering data, a check known as validation check can be
performed on the data to ensure that the data is valid. This check is only
performed if a validation rule was entered in the table structure. A
validity check is set by entering an expression containing the acceptable
values. Expressions can be made up of numeric, text or date data,
relational operators and/or logical operators. The data of the Number
data type must not be enclosed in quotation marks, whereas that of the
Text data type must be enclosed in quotation marks. The data of the
Date/Time field must be enclosed by # signs. When you add a
validation rule, you can also add validation text in the validation text
property.

Validation text
The error message that is displayed when the validation rule is broken.
You may create your own error message to notify the user of the
problem. Validation text appears in a message box if you attempt to
enter invalid information in a text field for which there is a validity
check. If you do not display a message, a default error message will be
displayed.
Required property
This property could be set to Yes or No. When it is set to Yes, it is
necessary for the user to input data in the field. This feature is very
useful for ensuring that data is entered in certain fields that are relevant
for processing the data. You will receive a message indicating that this
is a required field.

Allow zero length property


Setting this property to Yes allows a zero-length string to be entered in
the field. You may only use this option in Text, Memo or Hyperlink
data types.

Indexed property
An indexed property will arrange records to facilitate fast searches of the
database. Selecting ‘Yes no duplicates’ prohibits duplicate records for
this field. Selecting ‘Yes – duplicates’ allows duplicates.

Inserting fields
Right-click on the box to the left on an existing field
Click on insert rows
Type the name of the new field

Deleting fields
Right-click on the row and click delete
Click yes when the confirmation box pops up

Changing field definitions


Changing the field names, data types, field descriptions or field sizes
involves the same steps that you used in adding a new field.

Setting a primary key


 Select the table and open it in design view
 Right click on the field name that you want to set as the primary key
 Choose the primary key option or select the primary key icon
 Close the database window and choose OK to save the changes

Establish relationships
Relationships allow you to join the tables to share records, thereby
preventing the duplication or repetition of data.

When you are about to set up a relationship between two tables, you can
follow the following rules:
 Both tables must have at least one field containing common data
 The fields containing common information must be of the same data
type
 At least one of these fields must be a primary key

Linking tables
 Select database tools, then click on relationships
 Select the tables you want to link by clicking on them and clicking
the add button
 Select the primary key and drag it to the foreign key of the second
table
 Check the enforce referential integrity box (This will ensure that the
related tables correspond with each other, and it will not let you
create the relationship if they do not correspond.)
 Select the create button to create the relationship
 Now the relationship is set between the two tables and you can
retrieve information from both of them

4. Manipulate data in a database

Forms
Forms are similar to user interfaces, which allows database users to type data
into a database using specially designed templates, rather that straight into a
table. Using forms, we can format and display data, change or delete data and
create visual effects by adding colours, shades, lines and boxes to the fields.
Using the form wizard
 Select the forms object in the database window then double click the
create form by using wizard

 Select the table or queries you want from the drop-down list.

 From this window, choose the layout of the form and select one of the
four layout options

 Give your form a name then select finish

 Your form will be displayed with the first record of the table or query
being used for creating the form

Subforms
A subform is a form that is inserted in another form. The primary form is called
the main form, and the form that is enclosed in form is called the subform. A
form/subform combination is sometimes referred to as a hierarchical form, a
master/detail form, or a parent/child form.

Subforms are especially effective when you want to show data from tables or
queries that have a one-to-many relationship. A one-to-many relationship is an
association between two tables in which the primary key value of each record in
the primary table corresponds to the value in the matching field or fields of
many records in the related table. For example, you can create a form that
displays employee data, and contains a subform that displays each employee's
orders. The data in the Employees table is the "one" side of the relationship. The
data in the Orders table is the "many" side of the relationship — each employee
can have more than one order.
1. Shows the data from the “one” side of the relationship
2. Shows the data from the “many” side of the relationship.

Creating a subform
 Select the form you wish to create the subform for
 Right click on the form and open the design view
 Make the design space larger so that you can add the subform at the
bottom
 Select the subform option from the controls toolbar
 Select the data source you wish to use for the subform
 Add the required fields, then click next
 Choose the linking field, then click next
 Name the subform then click finish

Queries
One of the most powerful features of Database Management Systems is the
ability to perform queries: You can use queries to:
 Display part of a table
 Display records that meet a certain criterion
 Perform calculations
 Create/update tables
 Delete records

The query design window


The main part of the Query Design view is the Query Design Window. This is
where you fill in the details that control how your query will work. The
process of designing the query normally goes like this:

 Select the tables/queries that your query needs


 Double-click on the fields that your query will use in order to add them
to the Design view
 Fill in the field settings as appropriate (e.g. type in any criteria you are
going to use, select the sort order, etc)

Field settings
The following table explains what each field setting is for.
Row What it is for

Field This shows the name of the field. Since it is actually a


combo box, you can click it and change to another
field.
Table This shows the table that the field belongs to. This is
also a combo box
Sort By default this is blank, meaning that the field is
unsorted. But you can use the combo box to sort it in
ascending or descending order.
Criteria This is where you type the criteria to determine
whether a record is shown/affected by the query
Or You can also type criteria in these rows at the bottom

Adding fields
If you double-click on a field in the top half of the Query Design window, it
will be added to your query. The fields that have been added to the query will
be shown in the bottom half of the Query Design Window
Remove fields
 Select the field by clicking on the horizontal bar at the top of the field.
(Make sure that the whole mouse pointer changes to a black down
arrow.) The whole column should become highlighted.

 Press the delete key

Changing a field to something else


 Click the arrow next to the name of the table and change it to the correct
table (optional)
 Click the arrow next to the name of the field and change it to the correct
field

Repositioning a field
Select the field by clicking on the horizontal grey bar at the top of the field
Hold down the left mouse button and drag the field to the new position
Release the left mouse button

Basic queries

Displaying selected fields


If you want to list some of the fields in a table, create a query based on that table
and add those fields to the design view.

Sorting
If you need a query’s results to be sorted by a certain field, use the sort row in
the query design to set the sort order for those fields. Access will sort by the left
most field that has a sort order, then by the next field with the sort order and so
on

Placing criteria on a field


 Add the field to the design view
 Type an expression in the criteria row under that field
 If you want to hide the field, uncheck its show box
Using multiple criteria (AND)
If you have multiple criteria in the same row, only the records that meet all
criteria will be displayed

Using multiple criteria (OR)


If you want to display record that match any of a set of criteria, you place the
criteria on different rows.

Using * in criteria
The asterisk (*) has a special meaning when you put it in criteria. It acts as a
wildcard, which means ‘any group of characters or none at all’
Suppose you put the criteria sea*. This means the work sea followed by any
group of characters or none at all. So any of the following would meet the
criteria:
 Seas
 Seaweed
 Sea
 Sea shells by the sea shore
Criteria What is means Examples
Man* Anything that starts with MAN, MANURE,
the word ‘man’ Manchester United’
*man Anything that ends with Man, woman
the word ‘man’
*man* Anything that contains Man, manager,
the word ‘man’ woman, a man for
all seasons

Multiple table queries


In order to create multiple table queries, the tables must be joined to each
other. If you set a relationship between the tables, they will be automatically
joined when you add them to the Query Design

Once your tables are joined, you add different tables to your query design and
proceed as usual.

Calculated fields
 Select the option Query in Design View from the database window
 Select the table Personal Details from the Show Table dialogue box and
choose add
 Close
 Select the fields required
 In the empty column, type the name of the calculated field and its
formulae eg. Discount : [FeesRate] * .15. Please note that the equal sigh
(=) has been replaced with a colon (😊; the field name ‘FeesRate is
enclosed in square brackets and 15% is converted into its decimal form
as % is considered to be text.

Summarising data using queries


Queries can also be used to summarise data. For instance, you could use a
query to find the total of an order.

Finding an overall summary


 Add the field that you want to summarise to the query design
 Make sure that the total row is visible by clicking the totals button near
the top of the window
 Change the field’s total row setting from ‘group by’ to whatever stastic
you want to find (min, max, average)

Reports
Reports are used to present the information retrieved from the tables of a
database in a presentable manner so that it is useful and appealing to the user.
They can be created based on queries or tables. You can group, sort and have
summary features incorporated into a report.

 In the database window, click on the reports tab


 Double click on the create report by using wizard option
 Choose the fields from the tables or queries from the drop-down list
 Group the records by desired field (if necessary)
 Select next to get to the new window
 If you have included grouping and the report contains fields with
numeric values, a summary options button will be present for you to
include some summary features. Click on the summary options button
and a new window will appear for you to select your choice of summary
features
 Choose your desired layout and paper orientation
 Choose the style for the report
 Give your report a title then select finish

Modifying your report


 Select the report you want to open by single clicking it
 Right click on the report selected and choose the design view option
 Make the necessary modifications

Edit the report title


 Double-click the label containing the report title to place the cursor in
the label.
 Type the text you want to use as the report title, and press ENTER when
you have finished.

You might also like