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

Chapter 5

Uploaded by

yousefsawaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Chapter 5

Uploaded by

yousefsawaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Ch.

5: Introduction to databases Theory Notes

Chapter 5
Introduction to databases

Eng. Omar El Safty Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

5.1 Data types

1. Numeric data
Numeric data simply means numbers. Numbers come in a variety of different types:

Integer
• Positive or negative whole number
• Examples: 12, 45, 1274, 1000000, -3, -5735
Real/Decimal
• Positive or negative numbers with decimal/fractional parts
• Examples: 1, 1.4534, 946.5, -0.0003, 3.142
Currency
• Currency refers to real numbers that are preceded by a currency symbol
• Examples: £12.45, -£0.01, €999.00, $5500.
Percentage
• Percentage refers to any number that is followed by a percent symbol
• Examples: 100%, 25%, 1200%, -5%.

2. Alphanumeric/Text data
• Alphanumeric data refers to data made up of letters and numbers.
• Examples: DOG, "A little mouse", ABC123, [email protected].

3. Boolean data
• Boolean data can only have two values.
• Examples: TRUE and FALSE, YES and NO, ON and OFF, Male and Female.

4. Date/Time data
• Date/Time data is usually formatted in a specific way according to the setup of the
computer and the user’s preferences.
• Date Examples: 25/10/2007, 12 Mar 2008, 10-06-08.
• Time Examples: 11 am, 15:00, 3:00 pm, 17:05:45.

Eng. Omar El Safty 41 Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

Selecting data types


When we input data to a computer, we must analyze it and select appropriate data types for each
value.

Student Name: Ben Smith Alphanumeric

Student Number: 1234 Numeric Integer

Date of Birth: 10 July 1998 Date/Time

Year Group: 6 Numeric Integer

Telephone: (0232) 744 6574 Alphanumeric

Special Diet: Yes Boolean

Exam Score: 78% Numeric Percentage

Height: 1.67 Numeric Real

Fees Paid: $ 1500 Numeric Currency

The data type of a telephone number is Alphanumeric data as:


• Telephone numbers often have spaces, dashes or any other
symbol.
• Telephone numbers may start with a zero (numeric data
cannot start with a zero).
• Telephone numbers are not used in arithmetic operations

Eng. Omar El Safty 42 Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

5.2 Definition of database


A database is an organized collection of data related to each other.

5.3 Database terminologies

Term Definition Examples

Table A collection of related records Table of students

For a student the fields


could include:

• Student name
A column that contains one specific piece of
Field • Student ID
information and has one data type
• Age

• Address

• Gender

Field Name Title given to each field

A row within a table that contains data about a Details (all information) of
Record
single item, person or event one student

A field that contains unique data that identifies


Primary Key Student ID field
a record

Primary Key

Databases have two types: flat-file databases and relational databases.

Eng. Omar El Safty 43 Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

5.4 Database types

Flat-file database
Definition:
Database where all the data is held in a single table.
Example:

Relational database
Definition:
• Contains more than one table linked to each other
• It uses relationships
• It makes use of foreign key

Example:
For this example, all the data about customers is held in one file, and all the data about jobs is
held in another file. To create a connection between the two files, a relationship must be created

Eng. Omar El Safty 44 Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

Foreign keys
Definition:
• It is a primary key in another table
• Needed to act as a link between two tables.

Example:
'Customer ID' field acts as the primary key in the customer file and the foreign key in the job
file, thus enabling a relationship between the two tables.

Relationships
A relationship is a link or association between fields.

The relationship between the tables can be:


• one-to-one
• one-to-may
• many-to-many

Similarities between relational databases and flat file databases:


• Both use a primary key
• Both can create reports
• Both store data in records and fields in the table

Eng. Omar El Safty 45 Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

Advantages of a relational database over a flat-file database:


• Uses data integrity, which means no inconsistency in the data
• No duplication of data, so less data entry
• Saves time when entering data, as the user only has to input the data once
• Fewer errors are produced due to less data entry
• Saves storage space as data is only stored once
• Easier to add/modify/delete data
• Complex reports can be created
• Complex queries can be carried out
• Better security as some tables can be made confidential

Disadvantages of a relational database over a flat-file database:


• Takes more time to set up
• More complex than flat-file databases as more tables are used
• More complex to understand
• Sorting/Filtering of data is more complex
• Slower extraction of data
• Needs more processing power for complex queries
• Needs specialist personnel to set up the database

Differences between Primary Key and Foreign Key:


• Each table has one primary key, whereas a table can contain several foreign keys
• Primary key holds unique data, while the foreign key can be replicated in the table
• Primary key identifies the record, while the foreign key is used to link with the primary
key of another table

Eng. Omar El Safty 46 Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

5.5 Data validation


Definition:
• An automated computer check
• Ensures that the data entered into a computer is sensible/reasonable
• Ensures the data entered fits the set criteria

Validation check Description Example(s)

In an online form, a person’s


telephone number may be a
Checks if data is present and hasn’t
Presence check required field. So, if no data is
been left blank
entered, an error message will be
produced.

When registering a course in


Checks if value entered is available IGCSE, the session must be either
Lookup check
in a limited set/list of items June, November or Jan. No other
entry should be accepted.

• Checks whether numeric data is


To check if a student’s age is < 18
Range check within given/acceptable values
and > 0
• Uses two boundaries

• Checks whether numeric data is


To check if student’s age is < 18
Limit check within given/acceptable values
(no lower boundary)
• Uses one boundary only

If a field needs six digits, then


Checks if the input data contains inputting a five-digit or seven-digit
Length check
the required number of characters number should cause an error
message.
A person’s age should be numeric
Checks that the input data has the
Type check integer not alphanumeric, for
appropriate data type
example.
Checks the data is in a specific A date which should be in the form
Format check
format or fixed pattern of dd/mm/yyyy, for example.

Eng. Omar El Safty 47 Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

• A name would not contain


It checks that a string of characters characters such as %
Character check does not contain any invalid
characters or symbols. • A telephone number would
only contain digits
A validation check used in barcodes
to validate the correctness of the
barcode. Validating the correctness of a
Check digit
This is done by adding an extra digit barcode
that is calculated from the other
digits using some formula.

5.6 Data verification


Definition:
• Checks that the data on the original source document is identical to the data that you
have entered into the system
• Ensures that the data is copied/entered correctly

Visual check
Definition:
• Data is compared visually with the source document by a user
• The user is asked to confirm that the data entered is the same as the original
• If the user finds a difference, the data is re-entered

Double data entry


Definition:
• Data is entered twice by the same person // by two different people
• A computer checks that both entries are equal
• If they are not equal, an error message requesting to re-enter the data is displayed

Eng. Omar El Safty 48 Eng. Mustafa El-Komy


Ch.5: Introduction to databases Theory Notes

Similarities between visual verification and double data entry:


• Both are used to check that data has been entered correctly
• Both ensure that the data has been transferred correctly
• Both are used to check the data against the original data

Differences between visual verification and double data entry:


• In visual verification the user compares the data, whilst in double data entry the
computer compares the data
• In visual verification the data is compared with the original data source visually, whilst in
double data entry the data is compared with the previously entered data
• In double data entry, data is entered twice by the user(s)

Double data entry is different from Proofreading!


Proofreading is reading through the document to check grammar and
spelling mistakes without referring to the original source document.

Eng. Omar El Safty 49 Eng. Mustafa El-Komy

You might also like