Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 1: DB2 Introduction


DB2 Introduction

DB2 is the database that most COBOL programs on the mainframe talk to. This module introduces the key DB2 concepts you need first: what a database management system is, how the relational model stores data in tables, what normalization does, and how SQL talks to DB2.

What you will learn in this module

  • What a Database Management System (DBMS) is and why it exists
  • The advantages of a DBMS over plain files
  • How the relational database model organizes data into tables, rows and columns
  • How tables are related to each other through primary keys and foreign keys
  • What normalization is, and the first three normal forms (1NF, 2NF, 3NF)
  • The three families of SQL in DB2: DDL, DML and DCL
  • The main DB2 objects: databases, tablespaces, tables, indexes, views, synonyms and aliases

Database Management System (DBMS)

  • A DBMS stores information in electronic form.
  • It makes information available for sharing by users or programs.
  • It provides facilities to developers to define data to the system.
  • It provides facilities to users or programs to retrieve or change the data.
  • It provides facilities for security and recovery, so data is protected and can be restored after a failure.
  • It maintains information consistency throughout the database, so every user sees the same correct data.

Why this module matters for a COBOL programmer

  • Most COBOL batch programs on the mainframe read from and write to DB2 tables instead of flat files.
  • You will embed SQL inside COBOL programs (between EXEC SQL and END-EXEC) to fetch and update rows.
  • Understanding tables, keys and normalization helps you write correct SQL and debug wrong results.
  • SQL statements return a status code (SQLCODE) after every execution; knowing the objects involved makes those codes easier to read.

Your first look at SQL

  • SQL (Structured Query Language) is the language used to talk to a DB2 database.
  • Here is a simple SQL statement that reads rows from a table:-
    SELECT EMPNO, LNAME, FNAME FROM EMPLOYEE WHERE DEPTNO = 'B12'
  • This SELECT asks DB2 for the employee number, last name and first name of every employee in department B12.
  • All code examples in this module are plain SQL that you can run in any DB2 SQL tool.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant