IBM Informix Database Design and Implementation Guide
Total Page:16
File Type:pdf, Size:1020Kb
Informix Product Family Informix Version 11.50 IBM Informix Database Design and Implementation Guide SC27-3832-00 Informix Product Family Informix Version 11.50 IBM Informix Database Design and Implementation Guide SC27-3832-00 Note Before using this information and the product it supports, read the information in “Notices” on page B-1. This document contains proprietary information of IBM. It is provided under a license agreement and is protected by copyright law. The information contained in this publication does not include any product warranties, and any statements provided in this manual should not be interpreted as such. When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright IBM Corporation 1996, 2011. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Introduction .................................vii About this publication ...............................vii Types of users .................................vii Software dependencies ..............................vii Assumptions about your locale............................vii Demonstration database ..............................viii What's new in Database Design and Implementation for IBM Informix, 11.50 .............viii Example code conventions ..............................ix Additional documentation ..............................ix Compliance with industry standards ...........................ix Part 1. Basics of database design and implementation Chapter 1. Plan a database...........................1-1 Select a data model for your database ..........................1-1 Use ANSI-compliant databases.............................1-2 Differences between ANSI-compliant and non-ANSI-compliant databases .............1-2 Determine if an existing database is ANSI-compliant ....................1-5 Use a customized language environment for your database (GLS) .................1-5 Chapter 2. Build a relational data model .....................2-1 Build a data model ................................2-1 Overview of the entity-relationship data model .......................2-1 Identify and define principal data objects .........................2-2 Discover entities ................................2-2 Define the relationships ..............................2-4 Identify attributes ................................2-9 Diagram data objects ...............................2-11 How to read E-R diagrams ............................2-12 Telephone directory example ............................2-12 Translate E-R data objects into relational constructs .....................2-13 Define tables, rows, and columns ..........................2-13 Determine keys for tables .............................2-14 Resolve relationships ...............................2-17 Resolve m:n relationships .............................2-17 Resolve other special relationships ..........................2-18 Normalize a data model ..............................2-19 First normal form................................2-19 Second normal form ...............................2-20 Third normal form ...............................2-21 Summary of normalization rules...........................2-21 Chapter 3. Select data types ..........................3-1 Define the domains ................................3-1 Data types ...................................3-1 Select a data type ................................3-1 Numeric types .................................3-3 Chronological data types..............................3-8 BOOLEAN data type ..............................3-11 Character data types (GLS) ............................3-11 Null values ..................................3-15 Default values ..................................3-15 Check constraints .................................3-16 Referential constraints ...............................3-16 © Copyright IBM Corp. 1996, 2011 iii Chapter 4. Implement a relational data model ...................4-1 Create the database ................................4-1 Use CREATE DATABASE .............................4-1 Use CREATE TABLE ...............................4-3 Use CREATE INDEX ...............................4-5 Use synonyms for table names............................4-6 Use synonym chains ...............................4-7 Use command scripts ...............................4-7 Populate the database................................4-8 Move data from other IBM Informix databases ......................4-9 Load source data into a table ............................4-9 Perform bulk-load operations ............................4-10 Part 2. Managing databases Chapter 5. Table fragmentation strategies ....................5-1 What is fragmentation? ...............................5-1 Why use fragmentation? ..............................5-2 Whose responsibility is fragmentation? .........................5-2 Fragmentation and logging .............................5-2 Distribution schemes for table fragmentation ........................5-2 Expression-based distribution scheme .........................5-3 Round-robin distribution scheme ...........................5-4 Create a fragmented table ..............................5-5 Create a new fragmented table............................5-5 Create a fragmented table from nonfragmented tables ....................5-5 Rowids in a fragmented table ............................5-6 Fragment smart large objects ............................5-7 Modify fragmentation strategies ............................5-7 Reinitialize a fragmentation strategy ..........................5-8 Modify fragmentation strategies ...........................5-8 Grant and revoke privileges on fragments ........................5-10 Chapter 6. Grant and limit access to your database ................6-1 Use SQL to restrict access to data ............................6-1 Control access to databases ..............................6-1 Grant privileges .................................6-2 Database-level privileges..............................6-2 Ownership rights ................................6-4 Table-level privileges ...............................6-4 Column-level privileges ..............................6-6 Type-level privileges ...............................6-8 Routine-level privileges ..............................6-8 Language-level privileges .............................6-9 Automate privileges ...............................6-10 Determine current role at runtime ..........................6-13 Use SPL routines to control access to data ........................6-13 Restrict data reads ...............................6-14 Restrict changes to data..............................6-14 Monitor changes to data .............................6-15 Restrict object creation ..............................6-16 Views.....................................6-16 Create views .................................6-17 Restrictions on views ..............................6-19 Modify with a view ...............................6-20 Privileges and views................................6-22 Privileges when creating a view ...........................6-22 Privileges when using a view............................6-23 Chapter 7. Distributed queries .........................7-1 iv IBM Informix Database Design and Implementation Guide Overview of distributed queries ............................7-1 Distributed queries across databases of one Informix instance .................7-1 Distributed queries across databases of two or more Informix instances ..............7-1 Coordinator and participant in a distributed query .....................7-2 Configure the database server to use distributed queries ....................7-2 Syntax of a distributed query .............................7-2 Access a remote server and database..........................7-3 Valid statements for accessing remote objects .......................7-3 Access remote tables ...............................7-3 Other remote operations ..............................7-4 Monitor distributed queries ..............................7-5 Server environment and distributed queries ........................7-5 PDQPRIORITY environment variable .........................7-5 DEADLOCK_TIMEOUT parameter ..........................7-6 Logging-type restrictions on distributed queries .......................7-6 Transaction processing ...............................7-6 Isolation levels .................................7-6 DEADLOCK_TIMEOUT and SET LOCK MODE ......................7-6 Two-phase commit and recovery ...........................7-7 Part 3. Object-relational databases Chapter 8. Create and use extended data types in Informix .............8-1 IBM Informix data types ...............................8-1 Fundamental or atomic data types ..........................8-2 Predefined data types...............................8-2 Other predefined data types ............................8-3 Extended data types ...............................8-3 Smart large objects.................................8-5 BLOB data type.................................8-5 CLOB data type ................................8-6 Use smart large objects ..............................8-6 Copy smart large objects..............................8-7 Complex data types ................................8-7 Collection data types ...............................8-8 Named row types ...............................8-12 Unnamed