0% found this document useful (0 votes)
18 views19 pages

CH 8 1st Year (Nouman) Database Development

Uploaded by

hameed ullah
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)
18 views19 pages

CH 8 1st Year (Nouman) Database Development

Uploaded by

hameed ullah
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/ 19

DATABASE DEVELOPMENT

SHORT QUESTIONS

i) Name different types of database management systems.


Database management system:
DBMS stands for Database Management System. It is defined as:

“A collection of programs that enables user to store, modify and extract information
from a database is called DBMS.”

There are three types of database management system which are used commonly.
These are:

 Microsoft Access
 SQL Server
 Open Office Base

ii) What is OpenOffice Base?


OpenOffice Base is a database module1 of OpenOffice suite. It is an open source2
application program. It is fully featured database management system. It has wizards3
to help users to create database design easily i.e. to create tables, forms, reports etc.
Interactive4 databases are created in it that can manage data related to payroll,
inventory, assets, budgets, customers, sales orders and invoices etc.

iii.) How forms are useful in database?


A Form in MS Access is a database object used to display, edit and enter data from a
data source such as query or table.

1
The modules partition the system design or code. Some typical examples of modules are: whole programs or
applications. software libraries. classes, in an object-oriented language such as Java.
2
Open source software (OSS) is software that is distributed with its source code, making it available for use,
modification, and distribution with its original rights.
3
A wizard is a piece of software that simplifies complicated tasks, or instructs a user about how to complete a task
4
Interactive database management (IDM) provides complete data editing at the time of initial data entry when
information is ‘fresh at hand’. IDM continuously checks all variables for acceptability, completeness, and
consistency

Chapter 8 |1 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
Forms contain controls such as Labels, Textboxes, Combo boxes, List and Command
buttons etc. Forms are used to:

 Enter, edit and modify data in the database.


 Display records one by one. It also provides navigation buttons which allows
users to navigate records.
 Search specific record.
 Link other objects e.g. User can open a report by clicking a command button on a
form.

In the following figure the data which the customer form is showing is retrieved from
database table where actual data is stored.

User can enter the record of new customer and click on insert record which will enter
the data into database.

iv.) Name common Access database objects.


MS Access database consists of various objects that are used to design database. Some
of them that are used commonly are as follows:

 Tables
Data is stored in tables. A table is a set of rows (records) and columns (fields).
 Queries
Queries are used to retrieve specific data from database.
 Forms
User can use from to enter, edit, display and modify data in the database
 Reports
Reports are used to organize or summarize data so that user can print it or view it
on the screen

Chapter 8 |2 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
v.) How primary key is assigned in a table?
Primary key of relational table uniquely identifies each record in the table. It is a field
which is also called a unique identifier of table such as CustomerID field in Customer
table etc.

Primary key is assigned in a table, in following way:

 Right click on the table that we want to set the primary key and then click Design
View on the shortcut menu.
 Select the field that we want to use as the primary key e.g. CustomerID
 On the design tab, in the tools group, click primary key as shown in figure below:

A key appears to the left of the field that we specified as the primary key as shown
below:

vi.) What is a report?


A report is a database object. Report is used to organize or summarize data so that user
can print it or view it on the screen. It is an effective way of presenting data using
attractive layout (‫) َوضع َقطع‬.

A report can be run at any time and will always reflect the current data in the database.
Reports are generally created for printouts (‫ )چھاپ کر نکال ہوا ورق‬but they can also be
viewed on the screen, exported to another program, or sent through an email message.

Chapter 8 |3 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT

viii) Name different navigation buttons in a form.


Navigation buttons are used to navigate records in a form. The names of navigation
buttons

Chapter 8 |4 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
LONG QUESTIONS
i.) Explain the following database objects.
1) Tables
2) Forms
3) Queries
4) Reports
1. Tables:
Table is a basic object of a database. It is used to store data that relates to one entity
type. In RDBMS is called relation and is consist of rows and columns

Each row in a table is referred to as a record which represents one entity instance. Each
record consists of one or more fields. Fields correspond to the columns in the table. For
example, if there is a table named as employee, then each row will contain a record of
different employee and each field of row contain different type of information of an
employee. Such as, first name, last name, address and so on.

Each Fields has specific data type i.e. numeric, text, date or time or some other type.

Example:

A table is created in database through Design View

 In first column, its field names are specified.

Chapter 8 |5 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
 In second column, its data type of each field is selected.
 In bottom window at general tab, the properties of each field are specified i.e. its
size, its caption, its default value etc.
 Then table will be saved by giving a proper name to it.

Data is entered into table through Datasheet view

2. Query:
Query is a statement that extracts information from the database.

Queries are used to retrieve specific data from a single table or multiple tables. The data
user want to see is usually spread across several tables and queries allow user to view it
in a single datasheet. User can retrieve subset of rows (records) as well as subsets of
columns. Certain queries are updatable, means they can edit the data in the table.

Queries come in two basic varieties:

 Select query
 Action query

a. Select query:
A select query simply retrieves the data and makes it available for use. The results can
be viewed on screen, print it out or copy it to the clipboard.

b. Action query:
As its name implies it is used to perform different actions with data. Action can be used
to create new tables, add data to existing tables, update data or delete data.

Chapter 8 |6 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
Query is shown in figure below:

In this example:

 Click on the Create tab in the ribbon at the top of the screen and then Click on
the Query Design button in the Queries group.
 Show Table Dialogue box containing tables name will appear. Double click on
each table which you want to include in query.
 Select the field names which you want to appear in query.
 In the bottom window, all the information about query is given i.e. which fields
are included in query and from which table. You can also specify the criteria
 After this save and run query to get the required result.

Chapter 8 |7 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
3. Forms:
A Form in access is a database object used to display, edit and enter data from a data
source such as query or table.

Forms contain controls such as Labels, Textboxes, Combo boxes, List and Command
buttons etc. Forms are used to:

 Enter, edit and modify data in the database.


 Display records one by one. It also provides navigation buttons which allows
users to navigate records.
 Search specific record.
 Link other objects e.g. User can open a report by clicking a command button on a
form.

In the following figure the data the customer form is showing is retrieved from database
table where actual data is stored.

User can enter the record of new customer and click on insert record which will enter
the data into database.

Example:

4. Reports:
A report is a database object. Report is used to organize or summarize data so that user
can print it or view it on the screen. It is an effective way of presenting data using
attractive layout (‫) َوضع َقطع‬.

A report can be run at any time and will always reflect the current data in the database.
Reports are generally created for printouts (‫ )چھاپ کر نکال ہوا ورق‬but they can also be
viewed on the screen, exported to another program, or sent through an email message.
Report is displayed in figure below:

Chapter 8 |8 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT

ii.) Explain different data types used in Access.


MS access has following data types:

Text:
It the default data type used in MS access. It used for entering text or combinations of
text and numbers. The maximum size of text field is 255 characters.

Memo:
It is also used for entering text but of larger amounts. It can store up to 65,536
characters. So, it can be used for descriptive (‫ )وضاحتی‬text (‫ متن‬,‫)لکھائی‬.

Number:
This data type is used for storing numbers. Various numeric subtypes are also available
in the Field’s Property Pane of Table Design window.

Auto number:
An AutoNumber filed is a numeric (Long Integer) value. Access automatically fills this
field with a number when user enters new record. First record of AutoNumber field is
assigned value 1. Access increments the AutoNumber field of last record by 1 to assign it
to new record. Its storage space is up to 4 bytes.

Chapter 8 |9 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
Yes/No:
It is a logical field in Access which use 1 for Yes (true) and 0 for No (false). User can
format this field to display Yes or No.

Currency:
This data type is used for amount of currency. Currency is written is special way with
specific comma and decimal positions. So, this field automatically adjusts comma and
decimal to their correct positions. It can hold up to 15 digits with dollar ($) sign and 4
decimal places. Its storage space is up to 8 bytes.

Date/Time:
This field is used to enter date and time, separately or in combination. Its storage space
is up to 8 bytes.

OLE object:
An OLE (Object Linking and Embedding) can store, pictures, audio, video or other objects
such as word document or Excel spreadsheet that is created in another program. Its
storage space is up to 1 GB.

Hyperlink:
It is used for hyperlinks. Hyperlink is a path (link) of another document or a web
address. A hyperlink address has up to four parts: the text that is displayed in the field,
the path to a file or URL, a sub-address which is a location in the file or page in the
website, and the text that is displayed as the tooltip.

iii) Describe two ways of creating a table in Access.


In a relational database, the tables store our data. If we don’t have tables, we don’t
have a database. Access gives us several ways to create tables, these are:

 Datasheet view
In Datasheet view, we build a table by entering field names and setting data
types manually. All we have to do is to click and type.
 Table templates
Table templates are pre-made tables that meet several common business needs.
For example, the Assets table template contains many of the fields, such as Item
and Purchase Date etc.
 Design view.
Design view lets user control every field and property in the table.

C h a p t e r 8 | 10 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT

Here we will create tables by using Datasheet and Design view.

Creating a database:
First we will create database. The procedure of creating database is explained below:

 Open MS Access and then click on FileNewBlank Database:

 Give meaningful name to database.


 Clicks on Create button to finish naming the database.

1. Create tables in datasheet view:


 Click on the Create tab in the ribbon at the top of the screen and then Click on
the Table button in the Tables group. The new table will be opened in Datasheet
view by default as shown in figure below:

C h a p t e r 8 | 11 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
 Now click on Click to Add to add new field to table
o Select required data type.
o Give Field Name
Do this step for each field you want to add in this table

 Enter data in rows beneath field Names.

 By default the table name is Table1. Change the table name according to
database requirement.
 Click Ok. The table is saved and created in datasheet view.

2. Create tables in design view:


 To create a table, select the Create tab in the ribbon at the top of the screen.
 Click on the Table Design button in the Tables group, as shown below:

 Add the fields to the table. For example, in the figure below fields of
Customer_ID, Customer_Name, Custome_City, Credit_limit etc. are added.

C h a p t e r 8 | 12 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT

 Save table and name it tblCustomer.

iv.) Explain the process of creating forms in Access.


User can use from to enter, edit, display and modify data in the database

Creating forms:
Forms are created in Access by using several automatic tools for creating forms. These
tools are located in the Forms group on the top Create tab in the Ribbon. It is shown as
under:

These tools include:

 The Form option is used to make a basic form. It shows a single record at a time.
 The Split form option creates a form showing one record on top and includes the
Datasheet view of the entire source table on the bottom.
 The Multiple Items option creates a form that shows all records at once. These
records look similar to the source table in Datasheet view.
 The Form Wizard creates form by the process of creating more customized
forms.

C h a p t e r 8 | 13 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
Create form using Form option:
It is the basic option for creating Form. It will show just one record at a time. It also
includes all fields in source table that can be modified by the user to add controls or
hide fields.

Form can be created in following steps:

 Highlight the table that we want to use as the source table.


 With the source table highlighted, select the Form option from the Forms option
group in the Create tab on the Ribbon.
 The new form is created and opens in the object pane window. The form created
is shown in figure below:

v.) Write the steps for creating relationships between tables.


Relationships:
Relationships are the links that relates data of two tables with each other. It associates a
primary key of one table with foreign key of another.

Creating relationships:
Relationship between two tables is created in following steps:

 Click on Database Tools tab in the Ribbon and then click the Relationships
command. It is shown in figure below:

C h a p t e r 8 | 14 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT

 When the “Show table” dialog box appears:


o Select each table name, then click Add for tables that we want to relate.
o After tables are added, close the Show table dialog box. It is shown below:

Now Relationship map is displayed that contains all the tables as shown below:

 For creating relationships move the mouse pointer to the primary key of first
table and drag and drop it to the foreign key of another table. Like in figure
below, Customer ID is the primary key in Customers table and foreign key in
Orders table.
 Here we drag the Customer_ID of customer table by pressing the left mouse
button and release onto the Customer_ID of Orders table by releasing the left
mouse button.
 Then the Edit Relationships dialog box appears, as shown below:

C h a p t e r 8 | 15 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT

 Select the Enforce Referential Integrity option.


 Click Create and the relationship is created.

vi.) Explain different types of queries used in Access.


Queries are used to retrieve specific data from a single table or multiple tables. The data
user want to see is usually spread across several tables and queries allow user to view it
in a single datasheet. User can retrieve subset of rows (records) as well as subsets of
columns. Certain queries are updatable, means they can edit the data in the table.

There are three types of queries in Access:

 Select
 Update
 Delete

Select Query:
The select query is the simplest and most common type of query available in MS-Acess.
This query is used to select and display data from either one or more tables depending
upon the requirement.

Query can be created by using Query Wizard and also by Design view. But the basic
steps are same. These are as follows:

 Pick the tables that we need to use as sources of information.


 Determine the fields that we needs to include from tables or another queries.
 Determine the criteria of query (optional). It is to limit the records that the
question returns.
 After the query is made it can be run to see the results.

C h a p t e r 8 | 16 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
Update Query:
The update query is an action query which changes a set of records according to criteria
(condition). User can modify huge numbers of records at a time by using where clause
of update queries. Using update query the user can modify the data of one field or many
fields of a table.

Delete Query:
The delete query is used to remove one or more rows of data from a relational database
table. It uses Where clause to determine the criteria of query. In delete query:

 The * with table name will delete all its records.


 If that table is linked with some other table than the records of that table will also
be deleted.

vii.) How can one-to-many relationship can be created between two


tables? Give example.
One-to-may relationship is that relationship in which on entity instance of an entity type
can be linked with many entity instances of another entity type.

Or

One-to-may relationship is that relationship in which one row of a table can be linked
with many rows of another table.

In the example explained here Customers entity type is making one – to – many
relationship with Orders entity type. It is to express that one customer can place many
orders.

To create this relationship, we have to follow these steps:

 Click on Database Tools tab in the Ribbon and then click the Relationships
command as shown in figure below:

 Add table customer and table Order


 Drag the Cid of table Customer and place it on the Cid of order table

C h a p t e r 8 | 17 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT

 Click on Enforce Referential integrity


 Click ok

C h a p t e r 8 | 18 M. Nouman Abid 1st Year


DATABASE DEVELOPMENT
MCQ's-Chapter 8

i) Which of the following is used to store data in a database?

A. Table B. Form C. Query D. Report

ii) _____ is a window that displays data for viewing, entering and editing information.

A. Table B. Form C. Query D. Report

iii) Which of the following is logical data type?

A. Text B. Memo C. AutoNumber D. Yes/No

iv.) ____is an open source application program.

A. MS Access B. Open Office Base C. SQL Server D. MS Word

v.) What is the maximum size of text field data type?

A. 253 B. 254 C. 255 D. 256

vi.) ____ Key is a unique key field in a table.

A. Secondary B. Foreign C. Composite D. Primary

vii) Which key is used to create one to many relationship between tables?

A. Secondary B. Foreign C. Composite D. Primary

viii)________ is used to display data in an organized manner so that users can print it.

A. Table B. Form C. Query D. Report

C h a p t e r 8 | 19 M. Nouman Abid 1st Year

You might also like