Applied Computer1
Applied Computer1
The term database refers to a collection of related data from which the users can efficiently
retrieve the desired information. In addition to the storage and retrieval of data, certain other
operations can also be performed on a database. These operations include adding, updating
and deleting data. All these operations on a database are performed using a database
management system (DBMS). Essentially, a DBMS is a computerized record-keeping system.
In this topic we will be introduced to the basic terminology used in a database management
system.
I.1 Definitions
Data can be anything such as a number, a person's name, images, sounds and so on. Hence,
data can be defined as a set of isolated and unrelated raw facts (represented by values), which
have little or no meaning because they lack a context for evaluation (e.g. ‘Monica’, ‘36’,
‘chief’ …). When the data are processed and converted into a meaningful and useful form, it
is known as information. Hence, information can be defined as a set of organized and
validated collection of data. For example, 'Monica is 35 years old and she is a chief'.
Strictly speaking, data refer to the values physically recorded in the database, whereas
information refers to the conclusion or meaning drawn out of it. With respect to database,
these terms are synonymous.
Other than data and information, one more term, knowledge, is frequently used with database
technology. Knowledge is the act of understanding the context in which the information is
used. It can be based on learning through information, experience and/or intuition.
Figure 1. Data, Information and Knowledge
Data Model: A data model is a representation of a real world situation about which data is to
be collected and stored in a database. A data model depicts the dataflow and logical
interrelationships among different data elements.
• Accurate: To be useful, information must be accurate at all levels because all further
developments are based on the available information.
• Precise: Information should be to the point, containing all the essential elements of
the relevant subject areas.
Decision-making is the process of identifying, selecting and implementing the best possible
alternative. The right information, in the right form and at the right time is essential to make
correct decisions.
Information is vital for communication and is a critical resource for performing work in
organizations. Business managers spend most of their day in communicating with other
managers, subordinates, customers, vendors and so on. A manager must keep track of the
information flow from the sources inside and outside the organization.
Information helps in making sense of our environment, which assists in achieving the
performance objectives. In fact, productivity is directly related to the availability and value of
the information and its application in the related context.
II.2.1 Field
A field represents one related part of a table and is the smallest logical structure of storage in
a database. It holds one piece of information about an item or a subject. For example, in a
database maintaining information about employee, the fields can be Code, Deptt, Name,
Address, City and Phone (see Figure 2).
II.2.2 Record
A record is a collection of multiple related fields that can be treated as a unit. For example,
fields Code, Deptt, Name, Address, City and Phone for a particular employee form a record.
Figure 2 contains nine records (0101–0109) and each record has six fields.
II.2.3 Table
A table is a named collection of logically related multiple records. For example, a collection
of all the employee records of a company form employee table. Note that every record in a
table has the same set of fields. Depending on the database software, a table can also be
referred to as a file. The collection of multiple related files (tables) forms the database.
A data type determines the type of data that can be stored in a column. Although many data
types are available, the four most commonly used data types are Character, Numeric,
Boolean and DateTime. The values for this data type vary widely depending on the database
management software being used.
Fig 5 : One-to-One
• One-to-many Relationship (1:M)
In many-to-many relationship, one record in a table can be related to one or more records in a
second table, and one or more records in the second table can be related to one or more
records in the first table. For example, One teacher teaches many students and a student is
taught by many teachers.
III.4 Keys
A key is a data item that allows us to uniquely identify individual occurrences or an entity
type. You can sort and quickly retrieve information from a database by choosing one or more
fields (ie attributes) to act as keys. For instance, in a student's table you could use a
combination of the last name and first name fields (or perhaps last name, first name and birth
dates to ensure you identify each student uniquely) as a key field. There exist many types of
keys:
• Primary Key:
A field or a set of fields that uniquely identify each record in a table is known as a primary
key. This implies that no two records in the relation can have same value for the primary key.
For example, your student number is a primary key as this uniquely identifies you within the
college student records system. An employee number uniquely identifies a member of staff
within a company. An IP address uniquely addresses a PC on the internet.
A primary key is mandatory. That is, each entity occurrence must have a value for its
primary key.
• Candidate Key:
In a table, there can be more than one field that can uniquely identify each record. All such
fields are known as candidate keys. One of these candidate keys is chosen as a primary key;
the other keys that are not chosen as primary key are known as alternate keys or secondary
keys.
• Foreign Key:
A field of a table that references the primary key of another table is referred to as foreign key.
Figure 13.3 illustrates how a foreign key constraint is related to a primary key constraint.
Here, the field Item_Code in the PURCHASE table references the field Item_Code in the
ITEM relation. Thus, the attribute Item_Code in the PURCHASE relation is the foreign key.
NOTE: The key composed of more than one field is known as composite key. Sometimes, it is
also known as concatenated key or structured key.
A composite key consists of more than one attribute to uniquely identify an entity occurrence.
This differs from a compound key in that one or more of the attributes, which make up the
key, are not simple keys in their own right.
For example, you have a database holding your CD collection. One of the entities is called
tracks, which holds details of the tracks on a CD. This has a composite key of CD name, track
number.
CD name in the track entity is a simple key, linking to the CD entity, but track number is not a
simple key in its own right.
Application exercise
For each of the following entities, list possible primary keys. Then, suggest secondary keys, if
any: Student, Course, Unit, Result, Classroom, Lecturer, Department, Attendance
Integrity ensures that the data in a database is both accurate and complete, in other words,
that the data makes sense. There are at least five different types of integrity that need to be
considered: Domain constraints, Entity integrity, Column constraints, User-defined
integrity constraints, Referential integrity. The data analysis stage will identify the
requirements of these.
• Domain Constraints: A domain is defined as the set of all unique values permitted
for an attribute. For example, a domain of Date is the set of all possible valid dates, a
domain of Integer is all possible whole numbers, and a domain of day-of-week is
Monday, Tuesday ... Sunday.
• Column Constraints: During the data analysis phase, business rules will identify any
column constraints. For example, a salary cannot be negative; an employee number
must be in the range 1000 - 2000, etc.
• User-Defined Integrity Constraints: Business rules may dictate that when a specific
action occurs, further actions should be triggered. For example, deletion of a record
automatically writes that record to an audit table.
• Referential Integrity: It implies that if a foreign key is defined in one table, any of its
value must exist as a primary key in another table.
V. DATABASE MANAGEMENT SYSTEM
V.1 Definition
To carry out operations like insertion, deletion and retrieval, the database needs to be
managed by a software package. This software is called a database management system
(DBMS). Hence, DBMS can be defined as a collection of interrelated data and a set of
programs to access that data.
Database system: Database system is a general term that refers to the combination of a
database, a database management system and a data model. This system is responsible for the
following data manipulation acts; data controlling, data retrieving, data maintenance and data
definition.
Advantages
• Sharing of Data: Sharing of data allows the existing applications to use the data in the
database simultaneously.
• Improvement in Data Security: DBMS can ensure that the only means of accessing
the database is through the authorized channel. Hence, data security checks can be
carried out whenever access is attempted to sensitive data. To ensure security, DBMS
provides security tools such as user codes and passwords.
• Maintenance of Data Integrity: Data integrity means the consistency and accuracy of
the data in the database.
• Better Interaction with Users: Centralizing the data in a database also means that
users can obtain new and combined information that would have been impossible to
obtain otherwise. In addition, use of a DBMS allows the users, who do not know
programming, to interact with the data more easily.
Disadvantages
• MySQL : MySQL is open source database management system, one of the most
popular dbms on the web. It is reliable, fast and also flexible.
• Microsoft SQL Server : Microsoft developed this relational database server. The
primary function of this software is to store and retrieve the data as requested by other
applications, whether those applications are on the same computer or running on other
computers across the network (including internet).