Database Design and SQL for DB2 - Softcover

Cooper, James

 
9781583473573: Database Design and SQL for DB2

Inhaltsangabe

Thorough and updated coverage of database design and SQL for DB2 are the focus of this guide for the relational database-management system used on IBM i computer systems. Suitable for classroom instruction or self-study, this book explains the most widely used database language and the way that language is implemented on a variety of computer platforms. Topics covered include database concepts, SQL inquiries, web applications, and database security, and the material is reinforced by numerous illustrations, examples, and exercises.

Die Inhaltsangabe kann sich auf eine andere Ausgabe dieses Titels beziehen.

Über die Autorinnen und Autoren

James Cooper is a professor and the program coordinator for the computer studies department at Lambton College. He lives in Sarnia, Ontario.


James Cooper is a professor and the program coordinator for the computer studies department at Lambton College. He lives in Sarnia, Ontario.

Auszug. © Genehmigter Nachdruck. Alle Rechte vorbehalten.

Database Design and SQL for DB2

By James Cooper

MC Press

Copyright © 2013 James Cooper
All rights reserved.
ISBN: 978-1-58347-357-3

Contents

Introduction,
Chapter 1: Database Concepts,
Chapter 2: Conceptual Design Using ER Diagrams,
Chapter 3: Normalization,
Chapter 4: Physical Database Design: Creating Tables,
Chapter 5: Database Constraints,
Chapter 6: Single-Table Queries,
Chapter 7: Updating Tables,
Chapter 8: Multiple-Table Queries,
Chapter 9: Subqueries,
Chapter 10: Views and Indexes,
Chapter 11: Embedded SQL,
Chapter 12: SQL Cursors,
Chapter 13: The Create SQL Program Command,
Chapter 14: Stored Procedures,
Chapter 15: Triggers,
Chapter 16: Additional SQL Topics,
Chapter 17: Database Security and the GRANT and REVOKE Statements,
Index,


CHAPTER 1

DATABASE CONCEPTS


Chapter Objectives

Upon completion of this chapter, you should be able to:

• Define database and database management system

• Describe the steps for the database development process

• Explain the purpose of conceptual, logical, and physical database design

• Explain the relational database model


Introduction To Database and Database Management System

A database management system (DBMS) is a set of software programs that control the organization, storage, and retrieval of data in a database. A database is an organized collection of related tables that can be joined to provide information to users. Common relational database management systems that include Structured Query Language (SQL) are IBM® DB2®, Microsoft SQL Server®, MySQL, Oracle®, Sybase, and others.

A DBMS is a software system that uses a standard method of cataloging, retrieving, and running queries on data. The DBMS manages incoming data, organizes it, and provides ways for the data to be modified or extracted by users or other programs.

A DBMS lets users create and access data in a database. The DBMS manages database requests so users and programs do not have to understand where the data are physically located on disk or who else may be accessing the data. In handling database requests, the DBMS ensures the integrity of the data; that is, it makes sure the data are available and are organized as intended. In addition, the DBMS provides security by ensuring that only those users and programs with access privileges can access the data.


Relational Database Model

The foundation of most commercial database management systems today is the relational database model, which was first introduced in the paper "A Relational Model of Data for Large Shared Data Banks," published by Edgar Codd in 1970 [Communications of the ACM 13 (6): 377–387]. Since the publication of this paper, the relational model has been developed extensively into common relational database management systems such as DB2, Microsoft SQL Server, MySQL, Oracle, and others. In addition to relational databases, there are also hierarchical, network, and object-oriented databases.


THE DB2 DATABASE

DB2 refers to an entire family of IBM databases:

• DB2 for i

• DB2 for z/OS

• DB2 for Linux, UNIX and Windows (also referred to as DB2 LUW)


This book uses the IBM database management system DB2 for i, which is referred to simply as "DB2" throughout the book.

DB2 for i is an integrated part of IBM i, the operating system that runs IBM's System i® hardware platform. DB2 is not purchased as a separate software product, and any application can take advantage of its features. DB2 provides a DBMS that all computer programs use to access data stored in DB2 databases.

As mentioned, a database is an organized collection of related tables that can be joined to provide information to users. In the DB2 database approach, tables are defined independently of any applications that use them. Data remains in independent, simple, linear tables, but indexes are created that indicate how the rows of the different tables relate to each other in the sense of the join concept. These indexes can be created before any queries are run, or they can be created at run time as the join query is executed.


Database Terminology

There are two groups of terms used interchangeably when discussing databases. The reason there are two sets of terms is that before the use of SQL, people used traditional system terms. With SQL, a new set of terms more representative of a typical spreadsheet type of relational table became more common. Thus, the non-SQL world sometimes uses different terms than the SQL world uses. The table in Figure 1–1 shows the relationship between the SQL relational database terms and the non-SQL terms.


The Importance Of Database Design

Database design is an important stage of a development project that should precede the coding and creation of a database. Before creating database tables, one should know exactly what kinds of tables need to be created. Consider how meaningless it would be to create a customer table before knowing what customer data a company needed to have. For example, some companies might need to know their customers' occupations, while others might not care what their customers do for a living. The general requirement for database tables, of course, is to store data that the organization needs so the data can be used effectively. Determining exactly what those needs are and how best to implement a database that meets the requirements clearly should happen before coding begins.

Determining business requirements and documenting them, including both data and processes that use data, are tasks often collectively referred to as "modeling" because the result of the effort is a model, usually in diagrams, of the way the business works and the data it uses. The part of this effort that concentrates on the organization's data requirements is called database design.

Once a data model is completed, there is a specification of what data needs to be stored and at least some of the ways in which the data is used. For example, the data model for a particular company might specify that the company needs to keep track of customers, including their names, shipping and billing addresses, telephone and fax numbers, and credit ratings. This data model might also document that the company needs complete customer lists, in order by the customers' names. From this model or specification, one can then decide which data should be stored in database tables. A data model says what the organization needs, not how a system will be implemented to address those needs.

A system to provide for storing, updating, and retrieving the data specified in a particular data model might be implemented in any number of ways. The task of deciding how to implement a system for a particular data model is called physical database design or database design. The term "database design" is often used as an abbreviated way to refer to both the logical data modeling and the physical database design processes.

A database model identifies what data are to be stored in a database, how the data will be used, and how the tables in the database are related to each other. A database model that is well designed reduces the need for changes. The final development step, or actual database implementation, is the coding and creation of the database tables...

„Über diesen Titel“ kann sich auf eine andere Ausgabe dieses Titels beziehen.