You are on page 1of 33

4

th
Generation
Programming
Languages
By: Meisam Mousavi (116722)
Approximate Time: 25 Min.
No. Of Slides: 33
Presentation Overview
Programming Languages Being Categorized
4
th
Generation Programming Languages
History Of 4GL
Why 4GL?
Different Types Of 4GL
Additional Components
4GL Advantages & Disadvantages
4GL In Action
ORACLE As A 4GE
Structured Query Language (SQL)
Microsoft English Query




Page 1 Of 33
5 Classes Of
Programming Languages
First Generation
Machine Language
Second Generation
Assembly Language
Third Generation
high-level programming languages, such as C, C++, and Java
Fourth Generation
Fifth Generation
languages used for artificial intelligence and neural networks
Page 2 Of 33
4
th
Generation Programming
Languages
A fourth-generation programming
language (or 4GL) is a programming language
designed with a specific purpose in mind such as
the development of commercial business
software.
fourth-generation languages are closer to
human languages than typical high-level
programming languages.
Most 4GLs are used to access databases.
Page 3 Of 33
History Of 4GL
The term 4GL was according to James Martin first
used in his 1982 book Applications Development
Without Programmers to refer to non-procedural high-
level specification languages.
A SPECIFICATION language is one that enables a
programming task to be performed by the
construction of a set of non-procedural statements.

In 1987 Grindley distinguished between a Pure and a
HYBRID 4GL
Page 4 Of 33
Why 4GL?
Programming effort
They can be easily learnt since there are
relatively few commands, functions and
structures.
The cost of software development.
Alter and maintain
Ease of use
Simplicity of design and implement
Page 5 Of 33
Why 4GL?
The time it takes to develop software
Programs written in a 4GL can be written very quickly.
Each statement written may generate a large amount of
code containing a high level of functionality and
productivity. For example, consider the SQL statement:

SELECT surname, line_no, ddress_line
FROM patient, patient_address
WHERE patient.nhs_no=patient_address.nhs_n
ORDER BY patient.nhs_no, line_no

To write the equivalent in a 3GL would require many lines
of code and the procedural and iteration structures that
are absent from SQL.
Page 6 Of 33
Different Types Of 4GL

Theory
Pure 4GL: A specification language made up of non-
procedural instruction sets.
HYBRID 4GL: A number of pure 4GLs combined with and
held together by a more procedural language.
Implementation
Report generators
Forms generators
4GLs (sometimes termed fourth generation environments)
attempt to automatically generate whole systems from
the outputs of CASE tools, specifications of screens and
reports, and possibly also the specification of some
additional processing logic.
Page 7 Of 33
Additional Components
Some 4GLs have integrated tools which allow for the
easy specification of all the required information.
James Martin's Information Engineering systems
development methodology
allow the input of the results of system analysis and design in the form
of Data Flow Diagrams, Entity Relationship Diagrams, Entity Life History
Diagrams etc from which hundreds of thousands of lines of COBOL
would be generated.
Oracle Corporations Oracle Designer and Oracle Developer
could be integrated to produce database definitions and the forms and
reports programs.

Page 8 Of 33
4GL Advantages &
Disadvantages
Being specification languages, their use
requires, in theory at least, no
programming task; the necessary code will
be generated directly from the
specification.
Can only address a small and very highly
specialized area of development
Page 9 Of 33
4GL In Action
Database query languages:
SQL
Oracle SQL*Plus
Progress 4GL
Data-stream languages:
AVS
APE
Iris Explorer
Screen painters and generators:
Oracle Forms

Page 10 Of 33
4GL In Action
Report Generators:
Oracle Reports
LINC
GEMBase
BuildProfessional
Informix-4GL
Focus
Metafont
RPG-II
S
IDL-PV/WAVE
Gauss
Mathematica

Page 11 Of 33
Oracle
As A 4GE
Page 12 Of 33
FOURTH GENERATION
ENVIRONMENT (4GE) ?
In order to provide an environment in
which a complex system can be
developed, a number of different types
of "pure" fourth generation languages
must be integrated, and further
procedural programming facilities must
be provided.

Page 13 Of 33
4GE Components
Typical 4GE components:
END-USER QUERY LANGUAGE (e.g. SQL),
SCREEN FORMATTER (e.g. Oracle's screen
painter in SQL*Forms),
REPORT GENERATOR.

Page 14 Of 33
4GE Components
DATA DICTIONARY :
Central to all fourth generation environments
A system database, rather than a user database,
which holds metadata as opposed to the data itself
and the DATABASE MANAGEMENT SYSTEM.
A place to store all the various schemas and
mappings in both source and object form
Cross-reference information :
Which programs use which pieces of the database
Which user requires which reports
Qhat terminals are connected to the system

Page 15 Of 33
DBMS Rules
The database management system
performs two functions:
Filehandler for the systems developed using
the components of the 4GE
It is the software that manages the data
dictionary.

Page 16 Of 33
Oracle as a 4GE
SQL*Plus Allows users to create and manipulate tables using SQL.
SQL*Forms An interactive applications generator for creating
advanced, forms-based applications.
SQL*Loader A module to simplify the process of the entry of large
quantities of data into tables.
SQL*Report A module for generating complex reports.
SQL*Menu A module to enable the coordination of forms by an
interactive menuing system.
SQL*DD Design Dictionary - a structured system to monitor and
control the development from the initial analysis to running and
maintenance.
EASY*SQL An interface for inexperienced users of SQL using a mouse
and screen graphics.
SQL*Calc An Excel compatible spreadsheet that may use database
data; the spreadsheet cells can call SQL statements.
SQL*Graph Provides a graphical representation of data retrieved from
the database.
SQL*Text A module for creating a forms interface to large text
databases.

Page 17 Of 33
SQL
Structured Query Language
Page 18 Of 33
SQL Command Types
Query Commands
Select
Create View

Update Commands
Insert
Delete
Update

Page 19 Of 33
A typical SQL query has the form:
select A1, A2, ..., An
from r1, r2, ..., rm
where P
Ais represent attributes
ris represent relations
P is a predicate.
The result of an SQL query is a relation.
Retrieving Data (Select Command)
Page 20 Of 33
Provide a mechanism to hide certain data from the
view of certain users. To create a view we use the
command:
where:
<query expression> is any legal expression
The view name is represented by v
create view all-customer as
(select branch-name, customer-name
from depositor, account
where depositor.account-number = account.account-number)
union
(select branch-name, customer-name
from borrower, loan
where borrower.loan-number = loan.loan-number)
A view consisting of branches and their customers
Retrieving Data (Views)
Page 21 Of 33
Modification of the Database
Delete all account records at the Perryridge branch

delete from account
where branch-name = Perryridge

Add a new tuple to account with balance set to null

insert into account
values (A-777,Perryridge, null)

Increase all accounts with balances over $10,000 by 6%, all other
accounts receive 5%.

update account
set balance = balance 1.06
where balance > 10000


Page 22 Of 33
Domain Types in SQL
char(n). Fixed length character string, with user-specified length n.
varchar(n). Variable length character strings, with user-specified
maximum length n.
int. Integer (a finite subset of the integers that is machine-dependent).
smallint. Small integer (a machine-dependent subset of the integer
domain type).
numeric(p,d). Fixed point number, with user-specified precision of p
digits, with n digits to the right of decimal point.
real, double precision. Floating point and double-precision floating point
numbers, with machine-dependent precision.
float(n). Floating point number, with user-specified precision of at least n
digits.
Null values are allowed in all the domain types. Declaring an attribute to be
not null prohibits null values for that attribute.
create domain construct in SQL-92 creates user-defined domain types
create domain person-name char(20) not null
Page 23 Of 33
Date/Time Types in SQL (Cont.)
date. Dates, containing a (4 digit) year, month and date
E.g. date 2001-7-27
time. Time of day, in hours, minutes and seconds.
E.g. time 09:00:30 time 09:00:30.75
timestamp: date plus time of day
E.g. timestamp 2001-7-27 09:00:30.75
Interval: period of time
E.g. Interval 1 day
Subtracting a date/time/timestamp value from another gives an interval value
Interval values can be added to date/time/timestamp values
Can extract values of individual fields from date/time/timestamp
E.g. extract (year from r.starttime)
Can cast string types to date/time/timestamp
E.g. cast <string-valued-expression> as date

Page 24 Of 33
Entity Management Commands
An SQL relation is defined using the create table command:
create table branch
(branch-name char(15) not null,
branch-city char(30),
assets integer)

The drop table command deletes all information about the dropped
relation from the database.

The alter table command is used to add attributes to an existing relation.
alter table r add A D

The alter table command can also be used to drop attributes of a relation
alter table r drop A

Page 25 Of 33
Embedded SQL
The SQL standard defines embeddings of SQL in a variety of
programming languages such as Pascal, PL/I, Fortran, C, and Cobol.

A language to which SQL queries are embedded is referred to as a
host language, and the SQL structures permitted in the host
language comprise embedded SQL.

EXEC SQL statement is used to identify embedded SQL request to
the preprocessor
EXEC SQL <embedded SQL statement > END-EXEC
Note: this varies by language. E.g. the Java embedding uses
# SQL { . } ;
Sample:

EXEC SQL
declare c cursor for
select customer-name, customer-city
from depositor, customer, account
where depositor.customer-name = customer.customer-name
and depositor account-number = account.account-number
and account.balance > :amount
END-EXEC

Page 26 Of 33
Dynamic SQL
Allows programs to construct and submit SQL queries at run time.

Example of the use of dynamic SQL from within a C program.

char * sqlprog = update account
set balance = balance * 1.05
where account-number = ?
EXEC SQL prepare dynprog from :sqlprog;
char account [10] = A-101;
EXEC SQL execute dynprog using :account;

The dynamic SQL program contains a ?, which is a place holder for
a value that is provided when the SQL program is executed.
Page 27 Of 33
Microsoft English
Query
Page 28 Of 33
What Is English Query?

With English Query, developers can use
their SQL and OLAP databases as a basis
to build an English Query application,
which allows end users to query the
database in English.



SELECT sum(Orders.Quantity) from Orders, Parts WHERE Orders.State='WA'
and
Datepart(Orders.Purchase_Date,'Year')='1996'
and
Part.PartName = 'ProductX' and Orders.Part_ID = Parts.Part_ID

Page 29 Of 33
How it works?
Page 30 Of 33
References
Microsoft English Query Tutorials
Microsoft SQL Server 2000 User Manual
http://portal.acm.org
http://burks.brighton.ac.uk/
http://www.soi.city.ac.uk/
http://en.wikipedia.org/wiki/4GL
http://encyclopedia.fablis.com/index.php/Fourth-
generation_language

Page 31 Of 33
Page 32 Of 33
Thanks For
Attention!

You might also like