Professional Documents
Culture Documents
SECTIONS
• Introduction.
o Objectives of the Project.
• System Analysis
o Identification Of The Need
o Preliminary Investigation
o Feasibility Study
Technical Feasibility
Economical Feasibility
Operational Feasibility
• Software Requirement Specification
• Design
o Data Flow Diagram (DFD)
o Menu Flow Diagram
o Database Design
• Screens & Validation Checks
• Reports
• Coding
• Limitations
• Bibliography
SECTION 1
INTRODUCTION
SALES MONITORING
Introduction:
There is a company manufacturing electronic items for selling. Very frequently they have
to do sales analysis, product analysis and salesman analysis.
Objective:
0 First block keeps a track of all the Sales Man and Items
1 Second block keeps a track of all the Sales Order and Item Details
2 Third block keeps a track of Report generation
SECTION 2
SYSTEM ANALYSIS
SYSTEM ANALYSIS
Identification of Need:
This step is initiation of System Analysis. An overview of the client’s requirement has
been done. The basic need of the client to opt for such kind of project is analyzed.
As per current marketing scenario, an entire system was required to track day-to-day
transactions, alarming for stock and defaulters, and timely generation of reports is the
basic features of this project.
Preliminary Investigation:
The have to keep records of their employee details, their payment details, advance
payment details.
Feasibility Study:
The objective of the feasibility study is not to solve the problem but to acquire
a sense of its scope . During the study, the problem definition is crystallized and
aspects of the problem to be included in the system are determined.
Consequently, costs and benefits are described with greater accuracy at this
stage.
It consists of the following:
1) Technical Feasibility:
This involves financial considerations to accomodate technical enhancements. If
the budget is a serious constraint, then the project is judged not feasible. In the
proposed system only the cost of developing and maintaining the application will
be taken into consideration by the company. There is no need for any special
hardware.
2) Economical Feasibility:
With the help of this application it will lead to decrease in cost of opening and
maintaining offices which will be more than the cost of developing and
maintaining the Application . Lesser manpower is needed to maintain a
application than a branch office which will again lead to decrease in cost.
3) Operational Feseability:
This Application is very easy to operate as it is made user friendly . Main consideration
is user’s easy access to all the functionality of the Application.
SECTION 3
I was assigned the duty for developing a computerized system known as “Sales Order
System”. Working in team reinstates the team for some common guidelines and
standard to be followed by all the team members across all team. For the optimum use
of practical time it is necessary that every session is planned. Planning of this project will
include the following things:
0 Topic Understanding.
1 Modular Break –Up Of The System.
2 Processor Logic For Each Module.
3 Database Requirements.
Topic Understanding:
It is vital that the field of application as introduced in the project may be totally a new
field. So as soon as the project was allocated to me, I carefully went through the project
to identify the requirements of the project.
Modules – This project consists of different interfaces which will be accessed through
a MDI (Multiple Document Interface) window. Different modules that
makeup this system are briefly described below:
Database Requirements:
Hardware Environment
Hardware is the term given to machinery itself and to various individual pieces of
equipment. It refers to the physical devices of a computer system. Thus the input,
storage, processing control and output devices are hardware.
Processor : Pentium-IV
RAM : 128 MB
HDD : 40 GB
FDD : 1.44 MB
CD-ROM : 52 X
Monitor : 14 inches Color Monitor
Keyboard : 104 Keys Keyboards
Printer : HP DeskJet 670 C
SECTION 4
DESIGN
Main
Menu
Clos
e
Sales SalesM
Salesm Ite Sale Analysis an
an Analysi
m s
technique. The entity-relationship (ER) approach was first described by Dr. Peter Chen
in a paper which appeared in the first issue of the ACM publication, Transactions on
Database Systems in 1976. It is now recognized as one of the most important tools in
the data administration tool kit. It is incorporated in various forms, into all major CASE
understood and used, the ER approach can greatly reduce the time needed during the
analysis phase of the development cycle and at the same time greatly increase both the
accuracy and completeness of that analysis. With only a few exceptions all popular
concentrate on trying to fit lists of data elements into one of the data structure models
which can be implemented by a DBMS, others on designing reports, screens, and files,
and still others on following trails of transactions through the various processing stages.
From these processes, flows, data elements, and/or outputs, they attempt to re-create
the real world. Many attempt to recreate the processes from the desired results.
Each method approaches the data problem differently, and their results, many times,
resemble the results of the blind men who examined the elephant: the one examining
the tail thought it felt like a rope, the one examining the sides thought it felt like a wall,
the one examining its legs thought it felt like a tree, and the one examining its trunk
thought it felt like a snake. In a sense they were all right, but, at the same time, none
was right.
In the business environment, examining only transactions, processes, outputs, or data
flows, or even a combination of all four, produces a picture which is correct as far as it
goes, but which is not a true or complete picture of the environment. The business
environment is also populated by people using things, and both people and things are
located in places. Any business description must not only include these people, places,
and things, but it must also start with them. These people, places, and things are called
entities. These entities interact with each other in various ways, and those interactions
People, either individually or in groups, work with things or provide services for other
people. Since both the people and the things are real (they physically exist), they must
be described and they must be located somewhere (in some place). Additionally,
relationships which exist between people and things, people and places, things and
places, different types of things, different types of places, and different types of people
These entities may be well defined, in that the firm may know a great deal about them,
or they may be vaguely defined, in that the firm may know very little about them. In
some cases, such as with either prospective customers or employees, the firm may only
know or suspect that they exist, but not who or where they are.
These entities may exist in large homogeneous groups where all members are capable
of being described in the same manner, or they may be fragmented into many different
subtypes, each with descriptions which are either slightly different, or in some cases
entities, the relationships may be well defined in that the firm may know a great deal
about them, or vaguely defined in that the firm may know very little about them, as little
The power of the ER approach lies in its ability to focus on describing entities of the real
world of the business and the relationships between them. By describing real world
entities through the identification and assignment of attributes to them and their
relationships, the analyst is describing how and why the business operates.
Although the business itself may change, sometimes dramatically, these types of
changes occur much less frequently than changes in the routine processes and
activities. Regardless of how the business changes, the entities of the business rarely
change. What may change, however, is the firm's perception of which attributes of those
entities are currently of interest. Some relationships between these business entities
may also change, but even these relationship changes occur infrequently. Thus by
understanding and properly describing these entities and the relationships between
them, the analyst can form a very stable foundation for understanding and analyzing the
business itself, and for properly recording the results of, or changes caused by, the
constrained, by three factors, all of which have to do with the analyst's understanding of
the business environment. These closely related factors are (1) entity identification, (2)
of interest to the firm, and naming them. The identification process must specify the
entity at the precise level of specificity which ensures that it is not so general as to be
meaningless, and yet not so specific that it fragments into too many subsets. For
example, people as an entity would be too general since it includes both customers and
employees, among others. On the other hand, full-time employees and part-time
employees would be too specific since both are employees and "full-time" and "part-
Entity definition consists of identifying which attributes of the identified entities are
needed by the firm and why those attributes are of interest. For example, is the firm
interested in the attribute "hobbies" or "clothing sizes" for the employees? If the firm
deals in sporting goods, the answer to the former might be yes. If the firm provides
uniforms for its employees, the answer to the latter might also be yes.
Business context involves identifying and defining the relationships which exist between
the identified and defined entities, and their relative importance to the firm as a whole
and to each of its specific parts. Business context also involves identifying and defining
the use or role of each entity within the firm. An entity's appearance, role, or use in one
firm may be entirely different in another firm; yet the entity itself is the same.
Just as an entity may have different roles or uses between firms, so also, each part of
the firm may have a different perspective on the business, and, consequently a different
perspective on the entities of the firm. This perspective does not change the fact of the
entity's existence, only the attributes and relationships of those entities which are of
interest to individual portions of the firm and their role or use in that firm.
The specific definitions of these entities and their relationships with other entities within
the firm are relevant only within the context of that firm and are totally dependent upon
the attributes of the entities which are of interest to the firm. An entity within one firm
may be only an attribute of an entity within another firm, and vice versa.
The importance of identification, definition, and context can be seen when one looks at
the formal definitions of the three key elements which form the heart of the ER
approach. These definitions form the basis for both the data analysis method and the
A definition
An entity is defined as a person, place, or thing which (a) is of interest to the corporation,
(b) is capable of being described in real terms, and (c) is relevant within the context of
A definition
relationship. An attribute must also be (a) of interest to the corporation, (b) describable
in real terms, and (c) relevant within the context of the specific environment of the firm.
An attribute must be definable in terms of words or numbers. That is, the attribute must
have one or more data elements associated with it, one of which may be the name of the
entity or relationship. An attribute may describe what the entity looks like, where it is
located, how old it is, how much it weighs, etc. It may describe why a relationship exists,
how long it has existed, how long it will exist, or under what conditions it exists.
A definition
A relationship is any association, linkage, or connection between the entities of interest
to the corporation. These relationships must also be (a) of interest to the corporation, (b)
describable in real terms, and (c) relevant within the context of the specific environment
of the firm.
It is important to note at this point that relationships exist only between entities, not
When the attributes name, age, and sex are added, we can distinguish men from
When the relationships are added, we know whether we are talking about a group of
To describe an entity, we must describe it in terms of its attributes and its relationships
complete a phrase such as "the entity is...," "the entity has...," "the entity contains...," or
Each attribute relates to the entity in hierarchic terms, that is, all attributes of the entity
are fully dependent upon the entity itself because individually and together they are the
entity. The question can still be asked, however, "How can we begin to identify these
entities?" Is, for example, the entity identified as customer (representing all customers),
customer? The answer is that it can be all of these, none of these, or more than these.
The specific identification of the entity has meaning only within the context of that firm.
However, most businesses can be described using a fairly restricted set of generic entity
types such as customer, product, machine, employee, location, organizational unit, etc.
An entity is whatever the business defines it to be, and that definition must make sense
within the context of the firm. Thus, an entity in one firm may be a subset of entities
included in the entity definition of another firm, or may be the global definition of the
entity used within another firm. These differences in identification can be illustrated by
An illustration:
A town planning board, with responsibility for community planning and zoning, would
describe that community in terms of its buildings, and further define those buildings into
It might be interested in which people or firms occupy or own those buildings, but for
their purposes that information would be an attribute of the building, just as the size of
the building, the number of floors, the number of windows and doors, and the cost of the
On the other hand, the local tax assessor doing a census or community directory would
be interested in the people who live and work in the community and firms located there.
The assessor would be interested in the names of the people, their incomes, length of
residence, amount of taxes paid, and where they live or are located (the buildings) within
the community. In this case the buildings become attributes of the people.
Neither the buildings nor the people have changed. They both still exist. The
perspective, however, has changed; the things of interest about those buildings and
The town council, would need to know all the information about both the people and the
buildings, along with information about roads, utilities, etc. In this case, both the
buildings and the people become entities in their own right, along with the relationships
between them (who lives or works where, who owns what, and so on).
This need for both attributes and relationships is consistent with the accepted dictionary
considered apart from its properties." Thus although the entity exists, its true form and
Without attributes all that is known about the entity is that it exists. The distinction
between an entity and its attributes, and the relationship between an entity and its
attributes, is so important that the ER diagram distinguishes between an entity and its
places, or things which have a common name, a common definition, and a common set
represents numerous people, places, or things which have a common name and
common descriptors and thus can be treated as a set. These entities interact (relate)
An entity, although it exists physically, only has physical substance when it is described
in terms of what it looks like, where it is, what it does, and how it relates to other entities.
Each component of that description is a property or an attribute of the entity. The sum
These entities are physically real and their real properties can be described; these
people perform actions, using and transforming both things and information (which is
contained on things as data). The common characteristic of all entities is that we can
describe them, and we use words and numbers for that description. Collectively these
words and numbers are data; individually they are data elements.
The fact that entities, especially in the data processing environment, are described by
data, does not make them data objects nor is every collection of data elements an entity.
Some writers have suggested that data entities are built from collections of data
elements in the same manner that a car is built from a collection of parts. In fact, an ER
model can be complete and meaningful with no traditional data elements at all. The
parts of a car were specifically chosen because each contributes something to the
overall design of the vehicle. Any number of different sets of parts could be assembled
and would result in a car, but a specific car can only be built from a specific set of parts.
A car is a thing. It is a subtype of the larger group of things called vehicles, and part of
another subtype called self-powered vehicles which transport people and things. Just
as there are many different types of vehicles, not all of which are cars (some may be
boats, planes, or trains), so too there are many different types of entities.
A final type of attribute needs to be discussed: attributes which do not describe the thing
itself, but what it does, how it is used, or why it is used. Those things that an entity does
are called activities; collectively they are called processes. The attributes which
The processes, or activities, of the business are in reality the actions that people take
with respect to things, places, or other people. These actions usually result in some
Sales Monitoring
System
H salesman_code
a
s
salesman_name
d_o_j
SalesMan
year_sales
Sells
item_rate
item_code
Item QOH
item_name
Has Has
Item_code
value_of_sale
salesman_code value_of_sale
Sales_Master Item_Detail
function. The technique starts with an overall picture of the business and continues by
analyzing each of the functional areas of interest. This analysis can be carried out to
precisely the level of detail required. The technique exploits a method called top-down
The result is a series of diagrams that represent the business activities in a way that is
clear and easy to communicate. A business model comprises one or more data flow
drawn, which is a simple representation of the entire system under investigation. This is
followed by a level 1 diagram; which provides an overview of the major functional areas
of the business. Don't worry about the symbols at this stage, these are explained shortly.
Using the context diagram together with additional information from the area of interest,
The level 1 diagram identifies the major business processes at a high level and any of
these processes can then be analyzed further - giving rise to a corresponding level 2
business process diagram. This process of more detailed analysis can then continue –
through level 3, 4 and so on. However, most investigations will stop at level 2 and it is
Identifying the existing business processes, using a technique like data flow diagrams, is
or refinement of an existing business process. However, the level of detail required will
(data flow diagrams). These are now explained, together with the rules that apply to
them.
This diagram represents a banking process, which maintains customer accounts. In this
example, customers can withdraw or deposit cash, request information about their
account or update their account details. The five different symbols used in this example
represent the full set of symbols required to draw any business process diagram.
External Entity
An external entity is a source or destination of a data flow which is outside the area of
study. Only those entities which originate or receive data are represented on a business
process diagram. The symbol used is an oval containing a meaningful and unique
identifier.
Process
A process shows a transformation or manipulation of data flows within the system. The
Firstly an identification number appears in the upper left hand corner. This is allocated
arbitrarily at the top level and serves as a unique reference.
Secondly, a location appears to the right of the identifier and describes where in the
system the process takes place. This may, for example, be a department or a piece of
hardware. Finally, a descriptive title is placed in the centre of the box. This should be a
simple imperative sentence with a specific verb, for example 'maintain customer
Data Flow
A data flow shows the flow of information from its source to its destination. A data flow is
represented by a line, with arrowheads showing the direction of flow. Information always
flows to or from a process and may be written, verbal or electronic. Each data flow may
be referenced by the processes or data stores at its head and tail, or by a description of
its contents.
Data Store
Data stores may be long-term files such as sales ledgers, or may be short-term
Resource Flow
A resource flow shows the flow of any physical material from its source to its destination.
For this reason they are sometimes referred to as physical flows.
The physical material in question should be given a meaningful name. Resource flows
are usually restricted to early, high-level diagrams and are used when a description of
External Entities
It is normal for all the information represented within a system to have been obtained
from, and/or to be passed onto, an external source or recipient. These external entities
may be duplicated on a diagram, to avoid crossing data flow lines. Where they are
duplicated a stripe is drawn across the left hand corner, like this.
The addition of a lowercase letter to each entity on the diagram is a good way to
Processes
When naming processes, avoid glossing over them, without really understanding their
role. Indications that this has been done are the use of vague terms in the descriptive
The most important thing to remember is that the description must be meaningful to
Data Flows
Double headed arrows can be used (to show two-way flows) on all but bottom level
diagrams. Furthermore, in common with most of the other symbols used, a data flow at a
particular level of a diagram may be decomposed to multiple data flows at lower levels.
Data Stores
Each store should be given a reference letter, followed by an arbitrary number. These
reference letters are allocated as follows:
In order to avoid complex flows, the same data store may be drawn several times on a
diagram. Multiple instances of the same data store are indicated by a double vertical bar
There are rules governing various aspects of the diagram components and how they can
Data Flows
For data flows the rules are as follows:
Data flows and resource flows are allowed between external entities and processes.
Data flows are also allowed between different external entities. However, data flows and
resource flows are not allowed between external entities and data stores.
Processes
For processes the data flow rules are as follows:
Data flows and resource flows are allowed between processes and external entities and
between processes and data stores. They are also allowed between different processes.
In other words processes can communicate with all other areas of the business process
diagram.
Data Stores
For data stores the data flow rules are as follows:
Data flows and resource flows are allowed between data stores and processes.
However, these flows are not allowed between data stores and external entities or
between one data store and another. In practice this means that data stores cannot
The context diagram represents the entire system under investigation. This diagram
should be drawn first, and used to clarify and agree the scope of the investigation.
The components of a context diagram are clearly shown on this screen. The system
The context diagram clearly shows the interfaces between the system under
investigation and the external entities with which it communicates. Therefore, whilst it is
often conceptually trivial, a context diagram serves to focus attention on the system
boundary and can help in clarifying the precise scope of the analysis.
The context diagram shown on this screen represents a book lending library. The library
receives details of books, and orders books from one or more book suppliers.
Books may be reserved and borrowed by members of the public, who are required to
give a borrower number. The library will notify borrowers when a reserved book
In addition to supplying books, a book supplier will furnish details of specific books in
Note, that communications involving external entities are only included where they
involve the 'system' process. Whilst a book supplier would communicate with various
agencies, for example, publishers and other suppliers - these data flow are remote from
the 'system' process and so this is not included on the context diagram.
Next, identify and add the external entities that communicate directly with the process
box. Do this by considering origin and destination of the resource flows and data flows.
Finally, add the resource flows and data flows to the diagram.
In drawing the context diagram you should only be concerned with the most important
information flows. These will be concerned with issues such as: how orders are received
and checked, with providing good customer service and with the paying of invoices.
The level 1 diagram shows the main functional areas of the system under investigation.
As with the context diagram, any system under investigation should be represented by
There is no formula that can be applied in deciding what is, and what is not, a level 1
process. Level 1 processes should describe only the main functional areas of the
system, and you should avoid the temptation of including lower level processes on this
diagram. As a general rule no business process diagram should contain more than 12
process boxes.
The level 1 diagram is surrounded by the outline of a process box that represents the
boundaries of the system. Because the level 1 diagram depicts the whole of the system
There are three different methods, which provide a practical way to start the analysis.
These are explained in the following section and any one of them, or a combination, may
There are three different methods, which provide a practical way to start the analysis.
These are introduced below and any one of them, or a combination, may prove to be the
system consists largely of the flow of goods, as this approach concentrates on following
Resource flow analysis may be a useful method for developing diagrams if the current
system consists largely of the flow of goods. Physical resources are traced from when
they arrive within the boundaries of the system, through the points at which some action
occurs, to their exit from the system. The rationale behind this method is that information
will normally flow around the same paths as the physical objects.
Data Flow Diagrams – Organizational Structure Analysis
The organizational structure approach starts from an analysis of the main roles that exist
within the organization, rather than the goods or information that is flowing around the
system.
Identification of the key processes results from looking at the organizational structure
and deciding which functional areas are relevant to the current investigation. By looking
at these areas in more detail, and analyzing what staff actually do, discrete processes
can be identified.
Starting with these processes, the information flows between them and between these
processes and external entities are then identified and added to the diagram.
Document flow analysis is particularly useful where information flows are of special
interest. The first step is to list the major documents and their sources and recipients.
This is followed by the identification of other major information flows such as telephone
and computer transactions. Once the document flow diagram has been drawn the
The section explains the process of top down expansion, or leveling. Furthermore, it
illustrates that whilst there can only be one context and one level 1 diagram for a given
Each process within a given business process diagram may be the subject of further
analysis. This involves identifying the lower level processes that together constitute the
or leveling.
In order to illustrate the process of top-down expansion, consider the three processes
shown within this business process diagram. No detail is shown, only the outline of the
process boxes, which have been identified during the drawing of a level 1 diagram.
Any area of a level 1 diagram is likely to require further analysis, as the level 1 diagram
Therefore, below the level 1 diagram there will be a series of lower level diagrams.
These are referred to as level 2, level 3, etcetera. In practice, level 2 is usually sufficient
In this example the process numbered 3, at level 1, will be investigated further thereby
In the level 2 diagram four processes of interest have been identified and the numbering
of these processes must reflect the parent process. Therefore the level 2 processes are
Suppose that of these four level 2 processes, one was of sufficient interest and
complexity to justify further analysis. This process, let's say 3.3, could then be further
these processes must reflect the parent process. Therefore these three level 3
processes are numbered 3.3.1, 3.3.2 and 3.3.3. Data Flow Diagrams –
Numbering Rules
The process boxes on the level 1 diagram should be numbered arbitrarily, so that no
priority is implied. Even where data from one process flows directly into another process,
this does not necessarily mean that the first one has to finish before the second one can
begin.
the meaning of the diagram. This is true within any business process diagram - as these
However, as the analysis continues beyond level 1 it is important that a strict numbering
convention is followed. The processes on level 2 diagrams must indicate their parent
process within the level 1 diagram. This convention should continue through level 3
The diagram on this screen clearly illustrates how processes on lower level diagrams
be at level 2 or level 3.
There are 3 useful guidelines to help you to decide when to stop the analysis:
Firstly, if a process has a single input data flow or a single output data flow then it should
Secondly, when a process can be accurately described by a single active verb with a
singular object, this also indicates that the analysis has been carried out to a sufficiently
low level. For example, the process named validate enquiry contains a single discrete
task.
Finally, ask yourself if anything useful will be gained by further analysis of a process.
If the answer is no, then there is little point in taking the analysis further.
Generate
Sell Goods Sale Receipt
SALES Stores
MONOTORIN Dept.
SalesMa G
n
Receive the
Receipt
Process the goods
sold
DATA BASE DESIGN
Tables
The core element in any database design is the table. Essentially a table is a
Our Employee contains three records. Notice that the three fields or columns
Name, City and Salary are all important to an employee. One would not create a
table with unrelated information in each row or record. For example, columns such
as Slope, Latitude, or Government would not be added to this table, but columns
such as Email, Address and Last_Name might be useful. The idea when designing
In the above example notice that each column stores a different kind of information.
The kind or type of information stored is called the datatype of the column. The
columns Name and City store text information, while Salary stores currency or
money information.
Above is the Employee table defined in Visual Case for Microsoft Access XP. When
you change the database type, the data types (Text, Currency, etc.) will change as
different database management systems have different datatypes that they support.
Notice that the Salary column is now just a number. This is because Oracle 8 does
not have support for a money or currency field. This is okay though since the data is
You can change the type of a database that you are designing in Visual Case. When
you change the type of a database, Visual Case will automatically change the
datatypes of the columns within the tables to match the new dbms. This is not exact
Indices
In a large database, tables will often have hundreds, thousands or even more
records in them. A large company may have tens of thousands of employees around
the world, each occupying a record in the Employee table. Indices are important in
An index is a set of columns from the table that have certain constraints on them.
In our employee table, we could create an index on the Name field indicating that it
must be unique. Our index would then be called a unique index, and if a new
record was added to the table that violated our index, an error would occur.
index called a primary key. The set of columns that make up a primary key are
special as they can uniquely identify a record in the table. Take another look at our
We can create a primary key on the Name column. This is valid for if we ask for the
employee named "Mary" only one record or row is found. Below, a new record has
Now, if we ask for the employee named "Mary" there are two results, the one in
Halifax and the one in Toronto. To solve the problem, we can add City to the
primary key. The combination of Name and City now uniquely identifies each record
in the table.
Column
You may have noticed that we still have a problem. We would like to have a primary
key as we need a way to uniquely id the employees, but it is likely that there is more
the example above) and set it to be automatically numbered. That is, each time a
new record is added to the table, the value is automatically set to a unique value. In
the example above, a primary key has been created on the Employee_ID column.
Columns that are in a table's primary key are underlined on the diagram.
Foreign Keys
After tables, foreign keys are arguably the most important thing in a relational
database. Once you have some tables in your database, a way is needed to connect
all of the data together. Foreign keys, are the easiest way to do it.
Above, the Employee table has been changed. You will recall that previously, the
City field was stored as text. This could create problems and waste time if each time
the city has to be typed in. In the table, you could end up with errors and
City_ID Name
1 Toronto
2 Vancouver
3 Montreal
4 Winnipeg
5 Halifax
Now in the Employee table, only the unique identifier of the City is referenced. This
• The city name is only stored once in the database. Multiple tables and
records may reference the same city, but in each case only a number is
stored, not the entire name. This can save a significant amount of space on
disk.
• Other information could be stored about a city in the City table. For example,
in Canada you may wish to store the English and French versions of a name
to display to different users. With the design above, the underlying data need
Foreign key relations can be used between any tables. A client may have many
purchases, a library may have many books, a school many classes and a class many
Employee table is the child and it references the parent table City. Visual
• The child table is said to be the owner of the foreign key. Above, the foreign
• The child table must include the columns defined in the primary key of the
parent table. That is, each record in the child table, must be able to
Multiplicity
In the example of Employee and City, the multiplicity is said to be many to one.
For each employee there is one city, but for each city there are many employees. In
Visual Case you can specify the multiplicity on a foreign key (unless not supported by
Recall the constraint on a foreign key that the child table must uniquely identify a
single record in the parent table. This means that the multiplicity of the parent table
is always one. The child table can have the following multiplicities:
• Many
• One
• Zero or Many
• Zero or One
On the rare occasion in your designs you will run into a situation in which you need a
many to many multiplicity on a foreign key. A course has many students and a
table. The way it works is that each record in the Student_Course_Connection table
connects a single student with a single course. Each instance of a student taking a
You now have all the basics required to design a relational database. Beginning with
tables you can build storage compartments for the various data that need to be
maintained in your system. Indices on the table allow for easier access as well as
control and validation over the data. Finally, foreign keys allow you to relate the
When designing your database try to keep each table focused and straightforward.
Each table should only have the information relating to the data being stored.
Also, look for situations where a related table would better serve the purpose as we
did above with the City field. In general, you want to avoid duplicating data entry
and storage.
Don't be afraid to have a greater number of smaller tables. In our student and
course example, the school may specify that a student can take no more than 6
in the Student table and avoid the need for the intermediary table to support the
many to many relationship. You need to think ahead though. What will be required
if down the line the rules are changed and a student can take eight courses. All of a
sudden you have to change the database design (and convert the existing data) as
well as your code and the user interface for your system.
List of Tables:
0
1
Database Description
0 Salesman File:
1 Item File:
3
4
5
6
7 Item Detail File:
0 Salesman Master:
1 Item Master:
3. Sales Master – I:
0 Sales Master - II:
Section 6
Reports
Outputs:
CODING
Option Explicit
Unload Me
End Sub
If rs.State = 1 Then
rs.Close
End If
List1.RemoveItem (List1.ListIndex)
End If
Form_Load
End Sub
rs.Close
End If
Text1.SetFocus
Exit Sub
Text2.SetFocus
Exit Sub
Text3.SetFocus
Exit Sub
End If
rs.AddNew
rs(0) = Label2.Caption
rs.Update
MsgBox "Inserted"
List1.AddItem Text1
code(UBound(code) - 1) = rs(0)
Form_Load
If rs.State = 1 Then
rs.Close
End If
Text1.SetFocus
Exit Sub
Text2.SetFocus
Exit Sub
Text3.SetFocus
Exit Sub
End If
rs.Open "update item set item_name='" & Text1 &
"',item_rate=" & Text2 & ",qoh=" & Text3 & " where
item_code='" & Label2.Caption & "'", cn,
adOpenForwardOnly, adLockOptimistic
MsgBox "Updated"
List1.List(List1.ListIndex) = Text1
Form_Load
End If
Text1.SetFocus
End Sub
cmdDelete.Enabled = False
ReDim code(0)
List1.Clear
cmdSave.Caption = "Save"
Text1 = ""
Text2 = ""
Text3 = ""
If rs.State = 1 Then
rs.Close
End If
If rs.State = 1 Then
rs.Close
End If
List1.AddItem rs(1)
code(UBound(code) - 1) = rs(0)
rs.MoveNext
Loop
End Sub
MDIForm1.Item.Checked = False
End Sub
cmdDelete.Enabled = True
Dim a As Integer
If rs.State = 1 Then
rs.Close
End If
rs.Open "select * from item where item_name='" & List1 &
"'", cn, adOpenForwardOnly, adLockOptimistic
cmdSave.Caption = "Modify"
Label2.Caption = rs(0)
Text1 = rs(1)
Text2 = rs(2)
Text3 = rs(3)
End Sub
Option Explicit
Unload Me
End Sub
Dim i As Integer
If rs.State = 1 Then
rs.Close
End If
Combo2.SetFocus
Exit Sub
txtqty.SetFocus
Exit Sub
End If
rs.Open "select * from item where item_name='" & Combo2
& "'", cn, adOpenForwardOnly, adLockOptimistic
qty = rs(3)
MsgBox "The quantity on hand is " & qty & " only."
txtqty.SetFocus
Exit Sub
Else
cn.Execute ("update item set QOH= " & qtyleft & " where
item_code='" & txtcode & "'")
End If
i = frmSales.MSFlexGrid1.Rows
frmSales.MSFlexGrid1.Rows = frmSales.MSFlexGrid1.Rows +
1
frmSales.MSFlexGrid1.TextMatrix(i, 0) = i
frmSales.MSFlexGrid1.TextMatrix(i, 1) = txtcode
frmSales.MSFlexGrid1.TextMatrix(i, 2) = Combo2
frmSales.MSFlexGrid1.TextMatrix(i, 3) = Text1
frmSales.MSFlexGrid1.TextMatrix(i, 4) = txtqty
Unload Me
End Sub
If rs.State = 1 Then
rs.Close
End If
Text1 = rs(2)
End Sub
ReDim code(0)
If rs.State = 1 Then
rs.Close
End If
Combo2.AddItem rs(1)
code(UBound(code) - 1) = rs(0)
rs.MoveNext
Loop
End Sub
Option Explicit
Unload Me
End Sub
value = 0
If rs.State = 1 Then
rs.Close
End If
Combo2.SetFocus
Exit Sub
End If
rs.AddNew
rs(0) = Label2.Caption
rs(1) = MaskEdBox1.Text
rs(2) = code(Combo2.ListIndex)
rs.Update
If rs.State = 1 Then
rs.Close
End If
Dim i As Integer
For i = 1 To MSFlexGrid1.Rows - 1
rs.AddNew
rs(0) = Label2.Caption
rs(1) = MSFlexGrid1.TextMatrix(i, 1)
rs(2) = MSFlexGrid1.TextMatrix(i, 4)
rs.Update
Next
If rs1.State = 1 Then
rs1.Close
End If
If IsNull(rs1(3)) Then
rs1(3) = value
Else
rs1.Update
If rs.State = 1 Then
rs.Close
End If
rs.AddNew
rs(0) = code(Combo2.ListIndex)
rs(1) = Month(MaskEdBox1.Text)
rs(2) = value
rs.Update
MsgBox "Inserted"
Form_Load
End Sub
ReDim code(0)
Combo2.Clear
MSFlexGrid1.Rows = 1
cmdSave.Caption = "Save"
If rs.State = 1 Then
rs.Close
End If
Combo2.AddItem rs(1)
code(UBound(code) - 1) = rs(0)
rs.MoveNext
Loop
Combo2.ListIndex = "0"
MSFlexGrid1.Width = 6975
MSFlexGrid1.ColWidth(0) = 500
MSFlexGrid1.ColWidth(1) = 1000
MSFlexGrid1.ColWidth(2) = 2000
MSFlexGrid1.ColWidth(3) = 900
MSFlexGrid1.ColWidth(4) = 1500
End Sub
If Button = 2 Then
PopupMenu MDIForm1.salespopup
End If
End Sub
Option Explicit
Unload Me
End Sub
If rs.State = 1 Then
rs.Close
End If
List2.RemoveItem (List2.ListIndex)
End If
Form_Load
Text1.SetFocus
End Sub
rs.Close
End If
Text1.SetFocus
Exit Sub
MaskEdBox1.SetFocus
Exit Sub
End If
rs.AddNew
rs(0) = Label2.Caption
rs(2) = MaskEdBox1
rs.Update
MsgBox "Inserted"
List2.AddItem Text1
Form_Load
ElseIf cmdSave.Caption = "Modify" Then
If rs.State = 1 Then
rs.Close
End If
Text1.SetFocus
Exit Sub
MaskEdBox1.SetFocus
Exit Sub
End If
MsgBox "Updated"
List2.List(List2.ListIndex) = Text1
Form_Load
End If
Text1.SetFocus
End Sub
Private Sub Form_Load()
List2.Clear
cmdDelete.Enabled = False
cmdSave.Caption = "Save"
Text1 = ""
'Text2 = ""
'Text3 = ""
If rs.State = 1 Then
rs.Close
End If
List2.AddItem rs(1)
rs.MoveNext
Loop
End Sub
cmdDelete.Enabled = True
MaskEdBox1.Mask = ""
If rs.State = 1 Then
rs.Close
End If
cmdSave.Caption = "Modify"
Label2.Caption = rs(0)
Text1 = rs(1)
MaskEdBox1 = rs(2)
'Text2 = rs(3)
'Text3 = rs(4)
End Sub
Private Sub add_Click()
frmItem_det.Width = 6000
frmItem_det.Height = 4500
frmItem_det.Top = 1500
frmItem_det.Left = 2000
frmItem_det.Show
End Sub
'ExitWindowsEx(0, 0) = 1
End Sub
End
End Sub
Me.Item.Checked = True
frmItem.Show
End Sub
End Sub
End Sub
frmSalesman.Show
End Sub
'Screen.MousePointer = vbHourglass
'CrystalReport1.Destination = crptToWindow
'Me.CrystalReport1.WindowState = crptMaximized
'CrystalReport1.PrintReport
'
'Screen.MousePointer = vbArrow
DataReport4.Show
End Sub
DataReport2.Show
''Screen.MousePointer = vbHourglass
''
''CrystalReport1.ReportFileName = App.Path &
"\Report1.rpt"
'''Me.CrystalReport1.SelectionFormula =
"{month_sales.salesman_code}={Sales_master.salesman
_code}"
''CrystalReport1.Destination = crptToWindow
''Me.CrystalReport1.WindowState = crptMaximized
''
''CrystalReport1.PrintReport
''Screen.MousePointer = vbArrow
End Sub
Public cn As New ADODB.Connection
If rs.State = 1 Then
rs.Close
End If
rs.Open "select max(" & f & ") from " & t & "", cn
End If
End Sub
Dim y, d, m As String
y = Year(dt)
m = Month(dt)
d = Day(dt)
Else
End If
End Sub
Limitations and Areas of Enhancement