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

Chapter 7 - Introduction to Database System

Chapter 7 introduces database systems, explaining that a database organizes data in tables with records and fields, facilitating data access and management across various sectors. It contrasts Database Management Systems (DBMS) with flat file systems, highlighting DBMS's advantages such as multi-user access, data integrity, and security. The chapter also covers key concepts like attributes, relationships, and data modeling, emphasizing the importance of correct data types and the use of Entity Relationship Diagrams (ERD) in database design.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter 7 - Introduction to Database System

Chapter 7 introduces database systems, explaining that a database organizes data in tables with records and fields, facilitating data access and management across various sectors. It contrasts Database Management Systems (DBMS) with flat file systems, highlighting DBMS's advantages such as multi-user access, data integrity, and security. The chapter also covers key concepts like attributes, relationships, and data modeling, emphasizing the importance of correct data types and the use of Entity Relationship Diagrams (ERD) in database design.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 1

CHAPTER 7
Introduction to
Database System
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 2

DATABASE
A database stores data in organized form. A database is composed of tables which contain
rows and columns. These rows and columns are called records and fields respectively.
Most databases contain multiple tables. Generally, a database is an electronic system that
facilitates easy access, manipulation and updating of data.

USES OF DATABASE
 Database can be seen in every field of life, for example industries, school, and banking.

 Databases can be large like NADRA databases which keep the multi millions of records.

 Goal of database is to minimize the loss and increase productivity of an organization.

 Databases help businesses to organize and track customers, inventory and employees.

 Database helps a business manage its customers.

 Database tells a retail business how much stock is in warehouse and on store shelves.

 Databases track the vast amount of finance circulating in a business enterprise.

DATABASE MANAGEMENT SYSTEM


A DBMS is modern version of database designing, organization and manipulation. This
mainly offers the solutions which a flat file system could not provide. Databases are
developed, maintained and controlled by the Database Management System (DBMS).
Here are some examples of popular DBMSs used these days…

 MySQL  Visual FoxPro  Oracle  IBM Db2  Microsoft SQL Server  PostgreSQL

CHARACTERISTICS OF DBMS
The DBMS has many characteristics. Some of them are…
 Multiple users can access DBMS and can view, add, edit and delete records.
 DBMS has tools like Queries, Views, Forms which help users to manipulate data easily.
 A DBMS is more secure and reliable.
 DBMS allow distribution of data in multiple tables. It ensures lesser duplication of data.
 Preparing backups and providing limited permissions to users are features of DBMS.
 DBMS can handle large and complex data more conveniently.
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 3

FLAT FILE SYSTEM


Early databases were relatively flat which means they were limited to simple rows and
columns, like a spreadsheet. A flat file is the older version of database. It stores data in a
single table structure. Flat file databases are usually in plain text format, with only one
record per line.

ATTRIBUTE
Attributes describe the characteristics or properties of an entity in a database table.
For example, if we have to define a student entity then we can define it with the set of
attributes like roll number, name, course etc. The attribute values, of each student entity,
will define its characteristics in the table.

Comparison – DBMS and Flat File System

DBMS FLAT FILE SYSTEM


Multiple users can access data Only one user can access at a time
simultaneously.

Capable of handling huge sets of data. Only one user can access at a time

Allows non-duplication and integrity. Increases duplicate and redundant data.

Supports online access. Does not support remote connections.

Good for small, medium and large Limited only to smaller data
businesses. management needs.
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 4

BASIC COMPONENTS OF A DBMS


The basic components of DBMS are discussed below…
 Table  Field  Record  Data Types  Views

Table
It is a collection of data elements organized in shape of rows and columns. A contact list
may be one of the simplest examples of a table.

Field
It is the smallest component in a database. It is where the actual data is stored during data
entry. All data fields in the same table have unique names. Fields are also called attributes
or columns. Multiple fields make up a data record, several data records make up a data
table, and several data tables make up a database.

Record
A single entry in a table is called a record. Records are also referred as tuples or rows. A record is made up
of two or several data items.

Data Types
All fields in a table must have some data type. Data type is a data storage format that can
contain a specific type or range of values. The data type of a field is a property that tells
what kind of data that field can hold. Here are some basic data types…

Data Type Description Examples

Integer Holds only whole numbers 156, -56, 6745

Floating Point Holds number with decimal points 4.8, 5.23, 778.56

Character Stores only one character A, B, c, d

String Stores alphanumeric Pakistan, C-345

Boolean Holds only Boolean values 1, 0

Date and Time Holds Data and Time 01-02-2022, 02:00

Views
In a database the data is stored in tables. However, we can see that data through views.
Views do not store data and just show the information virtually. Views maintain the
security of data and ensure that no changes occur in the original data.
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 5

IMPORTANCE OF CORRECT DATA TYPE


Data type determines the type of data that can be stored in a database table column. When
we create a table, we must decide the data type to be used for the column definitions.
Choosing the right data type for our tables, stored procedures and variable not only
improves performance but it also improves data integrity by ensuring the correct type of
data being entered in each field. Correct data type also affect what operators and functions
we can apply to them in queries.

DESIGN VIEW
 It displays the view which allows entering field names, data types and description in table.
 We cannot change database data in design view.

DATASHEET VIEW
 It displays view in a column/row format which allow to view, enter or manipulate data.
 In this view, we can change data but it will not allow changing format of the database.

Comparison – Table and View

TABLE VIEW
A database object that allows generating a
A database object or entity that stores logical subset of data from one or more
the data of a database.
tables.

Table is actual. View is a virtual table.

Table is an independent data object. View depends on the table.


Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 6

CREATE TABLE USING DESIGN VIEW


Following are the steps to create table using design view…
i. Click on Create tab and Table icon. Pull down View menu and choose Design View.

ii. A new table appears in Table Design View. The name assigned to table is Table1.

iii. Type the name of a field into the Field Name column.

iv. Use the drop-down menu in the Data Type column to assign the field a data type.

v. Repeat steps 4 until you have created all of the necessary table fields.

vi. Click the Save button in the Quick Access toolbar.

vii. Then type a name for the newly created table and click OK.

CREATE QUERY / VIEW USING DESIGN VIEW


Following are the steps to create query/view using design view…

i. Click on Create tab in Ribbon and pull down the Queries group and click on Query
Design button.

ii. In the Show Table dialog box, add the table or tables that you want to add to query
design view.

iii. Next, add the fields from these tables that you want to view in your query results or
view. If you want to add all of the fields of a table into your result set, you can click
and drag the first field in the table, shown as an asterisk.

iv. Once you have added all the necessary tables and fields to the query or view, click the
Close button in the Show Table dialog box to close it and display the query design
view.

v. To run a query and view the result set, you can click the Run button in the Results
group of the Design tab in the Query Tools contextual tab on the office Ribbon.

vi. The result set looks like a table. This result set is a reflection of data from the selected
fields of the tables. It is also known as a view.

vii. Click the Save button in Quick Access toolbar. Type a name for your view and click
OK to save query.
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 7

RELATIONSHIP
When the database structures grew and became more complex, a lot of data started to
become redundant which means that data was being unnecessarily duplicated. This
resulted in the creation of relationships and Relational Database Management Systems
(RDBMS).
Three types of relationships can be defined between entities.
 One to One Relationship  One to Many Relationship  Many to Many Relationship

One to One Relationship


This type of relationship defines that a record in one entity can be connected to only one
record in another entity. This is not a very common type of relationship because the data
from related entities can directly be placed in a single entity.

One to Many Relationship


This type of relationship defines that a record in one entity can be connected to many
records in another entity. This is the most common type of relationship used in relational
databases.

Many to Many Relationship


In this type of relationship, one or more records of one entity are connected to one or
more records of another entity.

BENEFITS OF RELATIONSHIP IN DATABASE


Below are some of the few significant advantages of using relationships in a database…

Simple Model
A Relational Database system is the simplest model, as it does not require any complex
structuring or querying processes.

Data Accuracy
In the relational database system, there can be multiple tables related to one another. This
makes the data to be non-repetitive. Hence the accuracy of data is more.

Data Integrity
Data integrity is a crucial characteristic of the Relational Database system. It aids in other
significant characteristics like Ease of use, precision, and stability of the data.
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 8

Flexibility
A Relational Database system facilitates the increasing incoming amount of data, as well as
the update and deletes wherever required.

High Security
As the data is divided amongst the tables, it is possible to make a few tables to be tagged as
confidential and others not. This is easily implemented with a relational database, unlike
other databases.

DATA MODELING
Data modeling is a process of developing conceptual representation of data objects and
their relations. Data models are used to express how the information will be stored in
database. Data models can be used by database developers to create a physical database.
This saves a lot of time and efforts of developers.

There are three most important components of data models.


 Entity  Relationship  Referential Keys

ENTITY
In database terms, an entity is an independent table and its fields are known as attributes.
As an example, a Payroll database will contain an entity named Employees. The
Employees entity will contain various attributes like Employee ID, Name, Designation,
Salary, etc.

RELATIONSHIP
When the database structures grew and became more complex, a lot of data started to
become redundant which means that data was being unnecessarily duplicated. This
resulted in the creation of relationships and Relational Database Management Systems
(RDBMS).

REFERENTIAL KEYS
The relationships are configured by using referential keys on entities. The keys determine a
certain set of rules that must be followed by the data stored in a field of an entity. In larger
databases, keys are very important to uniquely identify a specific record. Two types of keys
are most commonly used in RDBMSs…
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 9

Primary Key
A primary key is used to uniquely identify a record in an entity. When a primary key is
applied to any attribute in an entity, it forces the rules of Primary Key onto that attribute.
These rules are…
 The attribute (field) must contain a unique value to identify a record.
 The value of the attribute where Primary Key is applied cannot be null.

Characteristics of Primary Key


A primary key has the following characteristics…
 There can only be one primary key for a table.
 The primary key consists of one or more columns.
 The primary key enforces the entity integrity of the table.
 No null columns are allowed.
 The primary key uniquely identifies a row.
 Primary keys result in clustered unique indexes by default.

Foreign Key
A foreign key is used to define the connection or relation between two entities. The
foreign key of one entity is configured to be connected to the primary key of another
entity.

Characteristics of Foreign Key


The foreign key has the following characteristics…
 A table may have zero or more foreign key defined.
 Foreign keys result in non-clustered unique indexes by default.
 One or more columns make up a foreign key.
 One null column per foreign key is allowed.
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 10

ER MODEL
Entity Relationship Model (ERM) or Entity Relationship Diagram (ERD) describes the
entities, attributes and relationships with their types in a simplified diagram. This model or
diagram can itself be used as the reference for designing an actual database. It can even be
used as a backup for the structure of a database. The ERD can be used in two ways…

 When the database has not been created yet


The ERD helps in creating a clear representation of the entire database based on user
requirements.

 When an existing database needs to be documented


The Database development tool features automatic creation of ERD based on existing
database.

Components of ER Diagram
ER Design is made up of different components like Attributes, Relationships, etc. There
are defined symbols and shapes to represent each one of them. Some of the shapes used to
define these components are…

Important ER Symbols

Symbol Description

A rectangle is used to define an entity. This can be any real-world


object.

An ellipse defines an attribute of an entity.


One entity may contain multiple attributes and are defined by
multiple ellipses.

Relationships are symbolically represented by diamond shape. It


simply states the type of relationship between two entities.

1 1
Connecting lines show the type of relationship between two entities.
1 M
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 11

STEPS TO DESIGN ER MODEL


i. Identify and design the entities based on the requirements of its users.

ii. Identify and design the attributes within the required entities.

iii. Identify the relationships required between entities.

iv. Define primary keys in interrelated entities.

v. Design foreign key relationship based on needs.

vi. Bind them to previously created primary keys.

vii. Generate an automated Entity Relationship Diagram.

IMPORTANCE OF ERD
ERD stands for Entity Relationship Diagram and it is basically a snapshot or brief of
various data structures. Following are some benefits/importance of the entity relationship
diagram.

Provides a Visual Representation of the Design


We need to have an ERD if we are looking to come up with a valuable database design.

Makes Effective Communication


ERD usually provides symbols for representing different kinds of information. This allows
a designer to effectively communicate what exactly the database may be like.

Simple to Understand
ERD is simple to understand and simple to create.

Highly Flexible
The ERD acts like the plan for the database and it make it possible for the creation of an
accurate design that demonstrates the needs of the project.
Computer Science - For Grade IX Written and Composed by SYED ATIF FEROZ 12

EXERCISE
1 What is a database? What are the uses of database?
2 What is a database management system? What are its characteristics?
3 What are the advantages of DBMS over flat file system?
4 What is a flat file system?
5 What are the basic components of a DBMS? Explain in detail.
6 Write the steps to create a table using design view.
7 What is an attribute?
8 Write the steps to create a query/view using design view.
9 Define relationship and its types.
10 What is data modeling? Name its components.
11 Define entity with example.
12 What is a referential key? What are its types?
13 Define ER model. What are the components of an ER diagram?
14 Write the steps to design ER model.
15 What is the difference between design view and datasheet view?
16 Differentiate between table and view.
17 List the properties of primary key and foreign key.
18 List some benefits of using relationships in database.
19 Discuss the importance of ERD in business.
20 Why it is important to decide the data type for each field?

Multiple Choice Questions


1 MS-Access 5 relationships 9 one to one relationship
2 It stores data in a… 6 string 10 an ellipse
3 entity 7 primary key
4 record 8 duplication of data

You might also like