Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

Database Notes

The document discusses database management systems and their components. It describes what a database is and advantages of using a database management system compared to manual storage. It also defines key database concepts like entities, attributes, records, tables, fields, primary keys and foreign keys.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Database Notes

The document discusses database management systems and their components. It describes what a database is and advantages of using a database management system compared to manual storage. It also defines key database concepts like entities, attributes, records, tables, fields, primary keys and foreign keys.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Database

Management System
Database

• A database is an organised collection of related


information such as accounting details of a
company. It provides easy and fast storage and
retrieval of information.
• Data can be stored manually, such as in a phone
book, in filing cabinet with many drawers that
contain information about patient at an hospital or
students information at a school. Each drawer
might contain different files of different things, like
grades, attendance, personal details.

• Disadvantages of manual storage of information:

1. Data is often duplicated.


2. It is time consuming to retrieve records.
3. Inconsistency of data.
4. Data cannot be shared easily.
Database management systems

• Database management systems (computerized


database) were developed to make the storage,
retrieval and updating of data/information faster
and easier.

• Databases are used to organise data in a clear and


consistent way. Most website and online
applications use databases. With so much data now
being shared online, data security is an important
issue.
Database management systems
• Databases are very powerful tools used in all areas
of computing. It is a key computing skill to be able to
organise data, create databases and control data
using query languages.

• One of the main benefits of computerised databases


is that they make it easy to store information so it is
quick and easy to find.
• For example, if you have music files on your
computer or mobile phones, a media application like
iTunes, Windows Media Player or Google Music
organises that data so it is easy for you to quickly
search for the artist or songs you want.
Database management systems
• Database software

• Database software includes off-the-shelf software


such as Microsoft Access, Libre Office Base, Oracle,
MySQL or NoSQL.
Advantages of Database management system

1. Information can be retrieved faster in ad hoc


situations using queries (ad hoc activity is not
planned in advance, but is done because a
particular situation made it necessary).
2. You can design and create your own queries with
minimal knowledge of databases.
3. There are reduced updating errors and increased
consistency as data is in a standardised form.
4. Data duplication is reduced.
5. Data entry, storage and retrieval costs are
reduced.
6. Security of data is increased.
7. You are able to present multiple views of data
using report features.

Disadvantages of Database Management Systems:

1. They are more time-consuming to design than a


manual database.
2. Initial training is required.
3. Suitable hardware and software are needed to
run the program.
4. They can be expensive to buy and maintain
Database structure
• A database is organised using a set of key
components. These include:
• entities - each recorded item
• attributes - details about the entity
• field - columns used to capture attributes
• record - one row of details about an entity
• table - a set of fields and records (rows and columns)
• primary key - unique number for an entity

• This is an example table of a flat-file database. The


entities are films and the attributes are details
about the films:
Database structure
• This is an example table of a database. The entities
are films and the attributes are details about the
films:
Database Terminology
• Table:
• The table contains all of the fields and the records
for one type of entity. All of the information you
enter in a database will be stored in a table. A
database may contain more than one table.

• Entity:
• When you build a database you are organising
data about entities. An entity is any item that has
its attributes stored as data. An entity could be
anything, eg a person, a book, a film, a country or
a football team.
• Attribute:

• The details about entities are called attributes. For


example, if we use a person as an entity, it can
have attributes such as: age, height, weight,
gender and nationality, among many others.
• When you design a database you need to think
about which attributes you want to store. For
example, the attributes of a film could include
title, duration, certificate, rating, genre, cast,
director and year of creation.
• Attribute:

• In a database of hotels, an individual hotel is the


entity, and the attributes could be ranking, awards,
location, photos, ratings and ID number.
• Record:
• a record is a collection of related fields. It contains
a single row and many columns. In relational
databases, records are also known as tuples.

• Field:
• a field is a single column in a table that stores data.
A field is sometimes referred to as an attribute.

• Primary key:
• Primary key contains a unique identifier for each
record. To make each record in a database unique
we normally assign them a primary key.
• A primary key is (row) from another within a
database table. needed to provide a unique way to
identify one record

• Fields marked as a primary key will not allow


duplicate entries in that field (column).

• Without primary keys, we could easily get


people/objects mixed up in a database, e.g. imagine
failing CXC because your exam score was mixed up
with that of another student with the same name.
Every student writing CXC have their own
registration number that can act as a primary key.
• Examples of primary key could be: email address,
passport number, National ID card number, Bank
account number, Student ID number, utility bill
account number (gpl meter number), student
exam number

• Even if a record is deleted from a database, the


primary key will not be used again. The primary
key can be automatically generated and will
normally just be a unique number or mix of
numbers and letters, for example: 090009000 or
DSC001004 (where DSC is Diamond Secondary
School)
• Candidate key - The candidate keys in a table are
defined as the set of keys that can uniquely identify
a record in the table. And every table has to have at
least one Candidate key. But there can be more than
one Candidate Key too.
• For example, in the table below, both Id and Email
can act as a Candidate key for the table as they both
contain unique and values.
• Secondary key (or Alternative key) -
• Secondary keys are those candidate keys which are
not the Primary key.
• There can be only one Primary key for a table.
Therefore all the remaining Candidate keys are
known as Alternate or Secondary keys. They can
also uniquely identify records in a table, but a a
different key was chosen as the Primary key.
• Foreign key - A foreign key is used to link tables
together and create a relationship.
• It is a field in one table that is linked to the primary
key in another table. The purpose of Foreign keys
is to maintain data integrity and allow navigation
between two different instances of an entity.
Data type and Field type:
• The form requesting information would indicate
what type or information it requires and in what
format. For example, for a Date of Birth field you
• might indicate the information should be in the
format mm/dd/yyyy.
• Data type or field type: the data or field type
determines the type of data that a field can store.

• Used to store blocks of text like notes up to 65536


characters long. Examples include ‘remarks’ and
‘project details’.
Data type Purpose
Short text Short Text (formerly Text) is a simple data type. A field with this
data type is limited to a maximum of 255 characters in length,
which is controlled by field size.
Long text Long Text (formerly Memo) is a data type that store pages. A
Long Text field can store up to 65,536 characters. Examples
include ‘remarks’ and ‘project details’.
Number Used to store numbers with or without decimal places.
Examples include ‘age’, ‘quantity’ and ‘average’.
Currency Used to store money values. Example include ‘salary’, ‘price’
and ‘discount’
Date/Time Used to store date/time type values. Example include ‘date of
birth’, ‘purchase date’ and ‘date joined’.
Yes/No Used for storing a yes or a no value. Example include ‘available’
and ‘passed’.
Attachment This is for attaching images and other files in your database, like
you would attach a file to an email.
• Field description

• Sometimes you need to explain what each field


represents. For example, you might have a field
named ‘Fees’ and you might need the users of
the database to be aware that they should enter
the fee that has been paid for one term.

• To do this, you would use a field description that


states ‘Fee paid for one term’. A field description
describes what is in the field. This description is
displayed in the status bar when you select this
field on the form.
• Field Size:

• On a form you fill in by hand there are only an


adequate number of spaces to fill in each field.
For example, a field that will store a number
representing a person’s age does not need the
same amount of characters as a field to store an
address.
• Similarly, in Access, you can specify the space for
certain fields such as text and number. This is
known as its Field size. A field size determines the
amount of information (in characters) a field can
store.

• In Access, there are default field sizes and a


maximum limit for each data type. The text and
number data types can be altered, but other types
are pre-set. The default field size of the short text
data type is 255 in Access 2007.
• Sometimes your field may not need so many
characters. For example, the field ‘First Name’ can
be set to 20, as the maximum number of
characters of a name is unlikely to contain more
than 20 characters.

• For the numbers data type, the field size can be


set to bytes, integer, long integer, single, double or
decimal. The default setting for Number is long
integer. The most commonly used field size for
numbers are Long integer and Double.
• Creating Tables

• Before you create a database, it would be wise


for you to plan what you plan what you it to
contain. You need to think about the field types
and field sizes. Such a plan is called the table
structure. For example if you want to create a
table called ‘Personal Detail’ that store the name,
address, date of birth, age, gender, average mark,
passed and fees rate of students, you might create
a table structure like the table below:
Field Name Field Type Field Size
Student ID Text 10
First Name Text 20
Last Name Text 20
DOB Date/Time Pre-set field size
Age Number Long integer
Gender Text 10
Average Mark Number Long Integer
Passed Yes/No Pre-set field size
Fee Rate Currency Pre-set field size

You might also like