Topic 9 - Database Programming
Topic 9 - Database Programming
Database program
Software that is used to manage data and information structured as fields, records and files. A
database program is the heart of a business information system and provides file creation, data entry,
update, query and reporting functions. The traditional term for database software is "database
management system"
Database programs let users create and edit single files interactively at the keyboard. However, as
soon as they want data in one file to automatically update another, programming has to be done.
Following are the common interactive tasks.
1. Create a File (Table) and Set Index Order
Each field in a record is defined by name, type and length. In order to keep the file, also called
a "table," in sequence, one or more fields are defined as key fields, upon which indexes are
created and maintained. The index is updated whenever records are added or deleted or any
data in a key field changes.
2. Create Data Entry Forms
Data entry is accomplished by designing a form to display each record. Data entry forms
contain field validation, which determines what data can go in and what cannot.
3. Update/Edit
In a single-user, one-file-at-a-time application, there is nothing to predefine here. Changing
data is a matter of opening the file and selecting the EDIT mode. However, in a multiuser
system, security must be administered and audit trails must be programmed.
4. View/Query
Browse an entire file or select records. Selected records are usually created as a temporary
file that can be sorted into a different sequence and, after viewing, can be deleted or saved for
later use.
The ease with which a query can be composed determines how often users ask their own
questions versus relying on IT staff. For example, retrieving data from two files, such as
customers and orders, or vendors and purchases, requires knowledge of how to link the files
for the query. Most database programs have a JOIN function, which creates a new file with
data from two existing files. Once a query has been composed, it can be saved for use again.
5. Reporting
Reports provide details and summaries in a more elaborate fashion than queries. Reports
have page and column headers and can be sorted into order by multiple fields. Once a report
description has been composed, it can be saved for use again.
6. Modify Structure
From time to time, it is necessary to add or delete fields, or change their lengths or possibly
their names. This function is similar to creating the record structure in the first place, except
that only modifications are made.
Coding
This is the process of translating application design (algorithms) into executable statements. The
tools for designing a program are flowcharts, Pseudo-code, decision tables and top down charts. The
commonly used tools however are flow charts and pseudo codes. The flowchart provides a pictorial
representation of the application design while the pseudo code is a non-formal language that provides
a way to create a logical structure, describing the actions, which will be executed by the application.
Coding is done using a suitable high level programming language and following the application
design. When coding follow the following best practices.
Know what the code block must perform
Indicate a brief description of what a variable is for (reference to commenting)
Correct errors as they occur.
Keep your code simple
Maintain naming conventions which are uniform throughout.
There are many commercial database management systems that perform these tasks. Programs like
Access (a Microsoft product) and Oracle are used worldwide.
There are many commercial products (Access, SQL Server, Oracle) that do database management
tasks. There are two primary advantages to using Application Programming Languages as a DBMS
instead of Access:
Your users don’t need to have any commercial product installed on their computers or know how
to use such products. This saves the users money.
By building a custom front-end, you limit what your user can do with the information within the
database. Under normal operation, commercial DBMS provide no such limits.
Interfaces in DBMS
A database management system (DBMS) interface is a user interface which allows for the ability to
input queries to a database without using the query language itself.
User-friendly interfaces provide by DBMS may include the following:
Menu-Based Interfaces - These interfaces present the user with lists of options (called
menus) that lead the user through the formation of a request.
Forms-Based Interfaces - A forms-based interface displays a form to each user. Users can fill
out all of the form entries to insert a new data, or they can fill out only certain entries, in which
case the DBMS will redeem same type of data for other remaining entries.
Graphical User Interface - A GUI typically displays a schema to the user in diagrammatic
form. The user then can specify a query by manipulating the diagram.
Natural language Interfaces - These interfaces accept request written in English or some
other language and attempt to understand them. A Natural language interface has its own
schema, which is similar to the database conceptual schema as well as a dictionary of
important words.
Speech Input and Output - There is a limited use of speech say it for a query or an answer to
a question or being a result of a request it is becoming commonplace Applications with limited
vocabularies such as inquiries for telephone directory, flight arrival/departure, and bank
account information are allowed speech for input and output to enable ordinary folks to access
this information.
Interfaces for DBA (Database Administrator)–Most database system contains privileged
commands that can be used only by the DBA’s staff. These include commands for creating
accounts, setting system parameters, granting account authorization, changing a schema,
reorganizing the storage structures of databases.
EXAMPLE OF AN APPLICATION PROJECT USING STRUCTURE OF A VISUAL C# WINDOWS
Application (Project) is made up of:
➢ Forms - Windows that you create for user interface
➢ Controls - Graphical features drawn on forms to allow user interaction (text boxes, labels, scroll
bars, buttons, etc.) (Forms and Controls are objects.)
➢ Properties - Every characteristic of a form or control is specified by a property. Example
properties include names, captions, size, color, position, and contents. Visual C# applies default
properties. You can
change properties when designing the application or even when an application is executing.
➢ Methods - Built-in methods that can be invoked to impart some action to a particular control or
object.
➢ Event Methods - Code related to some object or control. This is the code that is executed when a
certain event occurs. In our applications, this code will be written in the C# language
➢ General Methods - Code not related to objects. This code must be invoked or called in the
application.
Steps in Developing Application
There are three primary steps involved in building an application:
1. Draw the user interface
2. Assign properties to controls
3. Write code for event methods. Develop any needed general methods.
Testing
It is the process of evaluating a system or its component(s) with the intent to find that whether it
satisfies the specified requirements or not. Testing results in the actual expected and difference
between their results. It is used to identify any gaps, errors or missing requirements in contrary to the
actual desire or requirements. Database testing is focused on validating the following operations:
i). Loading of the database without violating data integrity
ii). Applications and database interface correctly
iii). The performance of the system satisfies the requirements.
Testing may require use of test data. The test data should be generated to determine how the system
handles the following inputs:
Invalid codes and invalid keys
Values having erroneous negative signs
Data threatening referential integrity
Null values
Inappropriate units of measure
Unauthorized attempts to middle the information in the data dictionary
Extreme values connected with unusually large hours worked or unusually large receipts of
goods
Un-authorized user’s attempts for changing the data.
Black Box Testing: The technique of testing without having any knowledge of the interior workings
of the application. The tester is oblivious to the system architecture and does not have access to the
source code. The tester will interact with the system's user interface by providing inputs and
examining outputs without knowing how and where the inputs are worked upon.
White Box Testing: This is a detailed investigation of internal logic and structure of the code. Also
called glass testing or open box testing. The tester needs to possess knowledge of the internal
working of the code.
Grey Box testing: In this technique the application is tested with limited knowledge of the internal
workings. Unlike black box testing, where the tester only tests the application's user interface, here,
the tester has access to design documents and the database.
Functional Testing: This is a type of black box testing that is based on the specifications of the
software that is to be tested. The application is tested by providing input and then the results are
examined that need to conform to the functionality it was intended for.
Unit Testing: It is used to isolate each part of the program and show that individual parts are correct
in terms of requirements and functionality. Unit testing is performed by the respective developers on
the individual units of source code assigned areas.
Integration Testing: Involves testing of combined parts of an application to determine if they function
correctly together. There are two methods of integration testing bottom-up integration testing and top
down integration testing.
System Testing: At this level the system is tested as a whole. Once all the components are
integrated, the application as a whole is tested rigorously to see that it meets quality standards.
Regression Testing: This testing is done to ensure that a change, such as a bug fix did not result in
another fault being uncovered in the application.
Acceptance Testing: This testing is conducted by the quality assurance team to gauge whether the
application meets the intended specifications and satisfies the client’s requirements. The QA team will
have a set of pre written scenarios and test cases that will be used to test the application.
Alpha Testing: This test is the first stage of testing .Unit testing, integration testing and system
testing are known as alpha testing.
Beta Testing: This test is performed after Alpha testing has been successfully performed. In beta
testing a sample of the intended audience tests the application. Beta testing is also known as pre-
release testing.
Non-Functional Testing: This involves testing of the application from its non-functional attributes.
Non-functional testing of Software involves testing the Software from the requirements which are non
functional in nature related but important a well such as performance, security, user interface etc.
Performance Testing: It is used to identify any bottlenecks or performance issues rather than finding
the bugs in software. There are different causes which contribute in lowering the performance of
software: Network delay, Client side processing, Database transaction processing e.t.c.
Load testing: A process of testing the behavior of the software by applying maximum load in terms
of software accessing and manipulating large input data. It can be done at both normal and peak load
conditions. This type of testing identifies the maximum capacity of Software and its behavior at peak
time.
Stress testing: This involves testing of software behavior under abnormal conditions. Taking away
the resources, applying load beyond the actual load limit.
Training of users
Training involves creating training documentation and end-user training. Determine how end users
will be instructed on the new product? This can in classrooms, on the job. It can be done by
individuals or done through computer e.g. use of videos. The documentation can be distributed to the
end user describing how to use the product (i.e.: help files, training manual, user manual). Most
importantly the focus should be to train people about what they need to know. It may therefore differ
for each job.
Conversion and loading (from old to new systems)
The process of transferring any existing data into new database and converting any existing
applications to run on the new system. This is only required if a new database will be replacing an
existing database. Modern database management systems (DBMS) have utilities for loading existing
files into new database. Such utilities require the specification of the source file and the target
database and then automatically converts the data to the required format of the new database file.