Vous êtes sur la page 1sur 32

Database Concepts

iSeries Database
DB2 UDB is the database Integrated with OS Relational database with Referential Integrity Database file types Interfaces to access files

Database Files
An iSeries Object of type *FILE Types:
Physical
Source Data

Logical Display
Screen Menu

Printer
3

Members
Contains the same format Contains sets of data of a file Can be a source or a data Maximum number of members 32767 Members in one LF member - 32

iSeries Database Files


Physical Files
PF-SRC or PF-DTA PF-DTA contains data Describes the way the data is actually stored

Logical Files
Contains no Data Used to arrange the data in a PF in different sequences Can change the length and the data type Can join more than one PF Join Logical Files
5

Data Files - Files, Records, Fields


A file member contains one or more records A record is made up of one or more fields which give it its record format or file description Each field contains a unique piece of information e.g. student no, first name, last name, address, telephone no, etc.
7

File Description
Described at Record Level and/or Field level Field-Level Description Name, length, data type, Validity Checks, etc. Called Externally-Described Files Record-Level Description Describes only the record length of the file. Called Program Described files File object must exist before using it in a program
8

File Description
Two major parts of the description
Record Format Description
Includes Field-Level description Describes the order of the fields in a record PF can have only one record format

Access path Description


Describes the order of retrieval of records Keyed Sequence
Defines the Key fields of a file

Arrival Sequence
9

Tools for Describing Database Files


Data Description Specifications (DDS)
AS/400 language to create source code for Files

Others:
SQL (Structured Query Language)

10

Describing file using DDS


DDS should be in the following order:
File-Level Entries (Optional) Record-Level Entries Field-Level Entries Key Field-Level Entries (Optional)

11

Example of DDS

13

Specifications (position 17)


R - Record Format Name J Join specification (LF only) K Key field name S Select Field Name (LF only) O Omit field name (LF only) Blank Field Name

14

File Level Keywords


UNIQUE Records with duplicate key values are not allowed DYNSLT Logical files, selection of records are done at processing time LF only FIFO, LIFO, FCFO REF PF only. To refer a field reference file REFACCPTH LF only. To copy the Access Path from a different file
15

File Level Keywords

16

Record Level Keywords


FORMAT To share the existing record format PFILE LF only. Identifies the PF from where data has to be retrieved JFILE LF only. Identifies the physical files from where data is access through JLF

17

Record Level Keywords

18

Field Level Keywords


ALIAS CMP COLHDG CONCAT (LF Only) DATFMT DATSEP DFT RANGE RENAME (LF Only) SST (LF Only) VALUES
19

20

21

Key - Field Level Keywords


ABSVAL DESCEND SIGNED UNSIGNED (Binary Representation) ZONE

23

Join Logical File


1. Optional: Specify file-level entries 2. Specify record-level entries - R 3. Specify join-level entries - J 4. Specify field-level entries 5. Optional: Specify key field-level entries - K 6. Optional: Specify select/omit-field level entries S/O
25

Join Logical File


JDFTVAL - File Level JDUPSEQ Join Level JFILE - Record Level JFLD - Join Level JOIN Join Level JREF Field Level

26

Join Logical File - Example

27

Field Reference File


A Physical file Used for reference only No data storage Created with MBR(*NONE)

28

Steps for Creating a Database File Create the source file (CRTSRCPF) which is named QDDSSRC (only done once) Create a source member, type PF Enter the source code using SEU Save source code and compile to create the file Put data into the file using DFU or SQL
30

Compiling the Source Code


CRTPF command or Option 14 in PDM
takes the source code and creates the object i.e. the physical file

31

Unique feature of iSeries Files


The record description is stored with the file object (externally described file) It can then be used by iSeries utilities The record description does not have to be coded again in programs that use it. Can be viewed using DSPFD, DSPFFD

32

Viewing records
RUNQRY QRYFILE(filename)
or

RUNQRY *N filename DSPPFM filename STRSQL

33

Managing database files


Copying (CPYF) and moving (MOVOBJ) Adding members to a file using CRTPF, ADDPFM, ADDLFM and CPYF commands CHGPF and CHGLF for file level change of attributes CHGPFM and CHGLFM for member level attributes like SHARE, Expiration date, etc Other operations include: CLRPFM, RGZPFM and DSPPFM
34

DFU
Data File Utility Part of ADT Used to manipulate (Add, Change and Delete) a database file Used to load the test data for the application Used to quickly load data for prototyping the application Can be invoked through STRDFU It creates a temporary program to enter data into the file
36

DFU

37

DFU

38

Vous aimerez peut-être aussi