Download Describing a Database File

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Database model wikipedia , lookup

Navitaire Inc v Easyjet Airline Co. and BulletProof Technologies, Inc. wikipedia , lookup

Transcript
Chapter Overview
SQL (Structured Query
Language) is an integrated part of
DB2 for IBM i and is replacing the use of
the Data Description
Specifications (DDS) language to
describe data on the system. This
chapter discusses DDS because many
systems still use it to describe data.
Copyright by Jim Buck
2012
2
Objectives
Tell
the difference between externally
described files and program-described
files.
Demonstrate
the basic operations of
SEU.
Use
PDM to move from a list of
libraries, to a list of objects, and to a
list of members.
Use
DDS to describe a simple
Copyright by Jim Buck
physical file.
2012
3
File Varieties
All
files in the IBM i operating system
(OS) are classified as object type
*FILE.
The
system recognizes more than 90
types of objects.
A *FILE
type is identified by a
subtype, or attribute.
When
a file is created, the system
assigns the attribute, which describes
Copyright by Jim Buck
4
how the file is to be used
2012 within the
File Varieties - cont.
Common file attributes:
 PRTF—Printer
files - format output from
programs or utilities to create spooled print files in
output queues.
 DSPF—Display
files - similar to printer files in
function, but they format data going to or coming
from display screens rather than printers.
 PF—Physical
files - two distinct functions: to
hold and organize user data, such as a customer
master file or sales transaction file; and to organize
source programs and source-data file descriptions
Copyright by Jim Buck
2012
5
File Varieties - cont.
Common file attributes:
LF—Logical
files are created over
physical database files and cannot be
created before the physical file or files
with which they are associated.
◦
◦
A logical file is always based on one
or more physical files.
Logical files do not contain data;
rather, they store access paths, or
Copyright
by Jim Buck
pointers, to records in
physical
files. 6
2012
Program-Described
Files

Physical files described at the record
level contain only a record name and a
record length.
Any
program that uses a file described in
this manner must supply field-level
attributes (e.g., field name, data type, field
length) for every field in the record.
Program-described
files are useful
when you need to convert older,
nonrelational files to the DB2 relational
database format, or whenCopyright
you need
to
by Jim Buck
2012
move files from another system
(AIX or
7
Externally Described
Files
Physical
files that contain detailed
field-level descriptions of their record
formats, as well as information about
how the files are to be accessed, are
referred to as externally
described files.
externally described file
contains field-level descriptions within
the file object itself, the file carries its
own record “blueprint.”Copyright by Jim Buck
8
An
Any
2012
user program or system utility
Externally Described
Files
Externally
described
files offer
Copyright by Jim Buck
2012
9
Externally Described
Files – cont.
Less-
tedious
programmi
Copyright by Jim Buck
2012
10
Creating an Externally
Described Database File
The process of creating and populating
an externally described database
physical file involves three distinct
steps:
Describe—
Describe the file’s record
format and field-level attributes at the
source-language level.
Create—
Create the file object by
compiling the source-language file
Copyright by Jim Buck
description.
2012
11
Methods of Describing
Database Files at the Field
Level
There are two approaches to describing files
at the field level.
SQL
- a standardized database language
used extensively not only in IBM OS but all
viable platforms. SQL’s wide support means
SQL-based applications are highly portable,
which provides a significant incentive for
learning SQL.
DDS
– a focus on DDS in this chapter
because it is a commonly used method to
code source descriptionsCopyright
for several
types
by Jim Buck
of files, including physical2012
and logical
12
Introduction to ADTS
Application Development
ToolSet (ADTS)
ADTS
is a valuable aid for creating
and maintaining programs and files.
PDM
is a workbench environment that
allows programmers and system
operators to navigate the three levels
of the OS’s object-based architecture:
the library level, the object level, and
the member level.
Copyright by Jim Buck
13
2012
ADTS – No longer
updated!
There were no enhancements to the
ADTS toolset as of version 6.1 of the
OS.
IBM
recommends that you use the
Eclipse-based workstation tool
Rational Developer for Power
(RDP) for development of traditional
IBM i applications.
We
introduce these traditional tools to
14
the new user becauseCopyright
of theby Jim Buck
2012
continued use of these products by
Why Learn these tools?
Many
companies still use this toolset.
Due to the ease of use and number of
programmers experienced with these
tools many companies have been
slow to discard this toolset.
Many programmers find that some
tasks are easier and quicker.

As
a result we don’t want students to
lose a job opportunity for lack of a
by Jim Buck
general understandingCopyright
of these
tools.
2012
15
The STRPDM Command
PDM is a workbench environment that
allows programmers and system
operators to navigate the three levels of
the OS’s object-based architecture:
The
library level.
The
object level.
The
member level.
Copyright by Jim Buck
2012
16
The STRPDM Command
You can start PDM by following a menu
path as discussed in previous chapters.
the STRPDM (Start PDM)
command on any command line.
Type
You
can also use the appropriate
“work with” command.
◦
WRKLIBPDM
◦
WRKOBJPDM
◦
WRKMBRPDM
Copyright by Jim Buck
2012
17
Work with Libraries Using
PDM
The Work with Libraries Using PDM screen
(WRKLIBPDM) displays a library name, type,
and text for each library.
Copyright by Jim Buck
2012
18
Work with objects Using
PDM
The Work with Objects (WRKOBJPDM) lists
all objects in a single library and—in the threecolumn format .
NOTE: pressing
F11 will change
the screen’s
format, to display
a single column of
objects.
Copyright by Jim Buck
2012
19
Work with Members Using
PDM
The Work with Members (WRKMBRPDM) lists
all members in a single source physical file.
Copyright by Jim Buck
2012
20
Creating a Member via
SEU
To create a new member from the Work with
Members Using PDM screen, you use the F6
command key. Pressing F6 invokes the STRSEU
(Start SEU) command.
Copyright by Jim Buck
2012
21
Creating a Member via SEU cont.
Then Fill-in the required parameters.
Copyright by Jim Buck
2012
22
SEU Line Commands
SEU
line commands let you
change the edit work area and
manipulate source member lines; for
example, you can move, copy, delete,
add, or insert lines.
A complete
list of these commands
are available from the work screen by
pressing the F1 Help key.
Copyright by Jim Buck
2012
23
SEU Line Commands –
cont.
Copyright by Jim Buck
2012
24
DDS Record-Format Entry
a DDS file description, several
different types of records may be
used.
In
Not
all are required for every file
description, but when used, they must
be entered in a specific order.
Copyright by Jim Buck
2012
25
DDS Record-Format Entry
For a physical file, the record types are:
name type; optional;
when used, must precede record type.
File—blank
name type; one required
for physical file.
Record—R
name type; describes
fields; follows record; almost always
present.
Field—blank
name type; optional; follows
Copyright by Jim Buck
field entries.
2012
Key—K
26
Field-Level Entries
For a physical file, the four required
attributes of a field are:
Name - For record and field names,
use from one to 10 characters, the first
of which must be uppercase alphabetic
(A–Z) or one of the special characters
@, $, or #. Subsequent characters can
consist of the numbers 0 through 9, and
the underscore character (_). Embedded
blanks are not allowed inCopyright
a name.
Within27
by Jim Buck
2012
a record format field, names
must be
Field-Level Entries - cont.
Data Type – The format the data is
stored.
Copyright by Jim Buck
2012
28
Field-Level Entries - cont.
Decimal Positions – used with
physical-file fields that represent
numeric data, whose type is packed
decimal, zoned decimal, or binary.
The
Decimal Positions value specifies
the number of digits to the right of the
decimal point—the fractional part of a
real number.
The
value can never be greater than
Copyright by Jim Buck
the length.
2012
29
Sample DDS Record
Description
Copyright by Jim Buck
2012
30
In Summary
Libraries are comprised of a number
of different types of objects.
Copyright by Jim Buck
2012
31
In Summary – cont.
Programmers and operators deal with
four kinds of files: physical files, logical
files, display files, and printer files.
Physical files hold data and may be
program described or externally
described.
Externally described files can be defined
at the field level using SQL, or they can
be available for DDS members.
Copyright by Jim Buck
2012
32
In Summary - cont.
To
facilitate the definition, creation,
and management of files and other
objects, PDM provides work-with lists
at the library, object, and member
levels.
When
files are defined using DDS, a
source physical file, QDDSSRC, is
created first.
◦
QDDSSRC holds descriptions of
individual files coded inCopyright
the DDS
by Jim Buck
2012
language.
33