VAX Rdb/VMS Guide to Database Design and Definition
Total Page:16
File Type:pdf, Size:1020Kb
VAX Rdb/VMS Guide to Database Design and Definition Order No. AA-N034B-TE VAX Rdb/VMS Guide to Database Design and Definition Order No. AA-N034B-TE December 1985 This manual shows how to design a logical database compatible with the relational data model. It then demonstrates how to build a physical database using VAX Rdb/VMS data definition statements. The material in this manual is tutorial in nature. OPERATING SYSTEM: VMS MicroVMS SOFTWARE VERSION: VAX Rdb/VMS V2.0 digital equipment corporation, maynard, massachusetts The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital I Equipment Corporation assumes no responsibility for any errors that may appear \. in this document. The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. No responsibility is assumed for the use or reliability of software on equipment that is not supplied by DIGITAL or its affiliated companies. Copyright © 1984, 1985 by Digital Equipment Corporation. All rights reserved. The postage-paid READER'S COMMENTS form on the last page of this document requests your critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: ACMS DEC US UNIBUS CDD MicroVAX VAX DATATRIEVE MicroVMS VAXcluster DEC PDP VAX Information Architecture DECgraph Rdb/ELN VMS DECnet RdbNMS VT DECslide TOMS Contents How to Use This Manual vii 1 Data Organization 1.1 Database Management Systems ...................... 1-1 1.1.1 Relational Database Model . 1-1 1.2 Data. .................. 1-2 1.3 Defining a Logical Database Model . .................. 1-4 1.3.1 IdentifyingFunctions . .................. 1-7 1.3.2 Listing Objects .............................1-12 1.3.3 Listing Data Items ...........................1-12 1.3.4 Normalizing Data ............................1-13 1.3.4.1 Eliminating Repeating Fields .................1-14 1.3.5 Identifying Primary Keys .......................l-16 1. 3. 5 .1 Checking Dependencies on the Key Field. .1-18 1.3.5.2 Inserting Foreign Keys .....................1-19 1.3.6 DefiningFields .............................1-19 1.3.6.1 Defining Field Names ..................... .1-20 1.3.6.2 Defining Field Data Types .................. .1-21 1.3.6.3 Defining Field Sizes .......................1-21 1.3.6.4 Field Definition Examples ...................1-21 1.3.7 DefiningRelations ...........................1-23 2 Creating a Database 2.1 The Logical Database ............................. 2-2 2 .2 Storage of Database Entity Definitions. 2-2 2 .3 Defining the Database . 2-3 2.3.1 NamingtheDatabaseFiles. 2-3 2.3.2 Database Size. 2-5 2.4 Defining Fields. ....................... 2-6 2.4.1 Global Attributes. ............ 2-6 2.4.1.1 Global Name . ............ 2-7 2.4.1.2 Data Type. ............ 2-7 2.4.1.3 VALID IF Clause . ............ 2-7 2.4.1.4 MISSING VALUE Clause ................... 2-8 2.4.1.5 DATATRIEVE Support Clauses ............... 2-8 2 .4. 2 Local Attributes. 2-9 2.4.2.l Local Field Names ........................ 2-9 2.4.2.2 Local DATATRIEVE Support Clauses ............ 2-9 2.4.2.3 COMPUTED BY Clause ....................2-10 iii 2.4.3 Using the DEFINE FIELD Statement ...............2-10 2.4.4 CreatingFieldNames . .2-11 2.4.5 Specifying Data Types. .2-12 / 2.4.6 Field Definition Options . .2-15 r\" 2.4.6.1 DATATRIEVE Support Clauses . .2-15 2.4.6.2 MISSING VALUE Clause ................... 2-16 2.4.6.3 VALIDIFClause . ..................2-17 2.5 Defining Relations. ...2-18 2.6 Defining Constraints . .....2-21 2. 7 Defining Indexes. .2-23 2.8 Defining Views .................................2-26 2.8.1 CreatingtheGUESTView ......................2-27 2.8.2 CreatingtheCURRENT_JOBView. .2-29 2.8.3 Creating the CURRENT_SALARYView .............. 2-31 2.8.4 CreatingtheCURRENT_INFOView ................ 2-32 2.9 Loading the Database .............................2-33 2.10 Verifying the Definition Phase .......................2-33 3 Defining Database Protection 3.1 The Access Control List........... ..... 3-2 3.2 Creating Access Control List Entries .................... 3-2 / 3.2.1 User Identifiers ............................. 3-3 3.2.2 RdbNMS Access Rights ........................ 3-4 3.2.3 Using the DEFINE PROTECTION Statement .......... 3-6 3.2.3.1 Specifying the Target of the DEFINE PROTECTION Statement . 3-6 3.2.3.2 Specifying the Location of the Entry ............. 3-6 3.2.3.3 The IDENTIFIER Clause . ..... 3-7 3.2.3.4 The ACCESS Clause .......... ..... 3-7 3.3 Building Access Control Lists ............ ..... 3-8 3.4 Putting the Access Control List in Order ...... ...3-12 3.5 Building an Access Control List for a Relation ... .....3·14 3.6 Defining Protection for Views . ...... ....3-14 3. 7 Invoking the Database ................. .....3-16 3.8 Changing and Deleting Protection .......... .....3-16 3.8.1 Changing an Access Control Entry (ACEl ... .....3-16 3.8.2 Deleting an Entry from an ACL. ...3-17 3.9 VerifyingtheACLsforaDatabase .....................3-18 iv 4 Restructuring a Database 4 .1 Changing Relations . 4-1 4.2 Changing Fields ..... 4-2 4.3 Changing the Database . 4-4 4.4 Deleting Relations ... 4-6 4. 5 Deleting Fields . 4-7 4.6 Deleting the Database . 4-8 A Definitions for the OVERNITE Database Index Figures 1-1 Reservation System Flowchart Showing Data Flow .1-10 1-2 Functions Share Data. .1-11 1-3 Objects in the Hotel Reservation System . .1-12 1-4 Data Items Logically Related by Object . .1-13 1-5 Removing Repeating Fields from the HOTEL Relation .1-14 1-6 Normalizing the HOTEL Relation Creates the RATES Relation. .1-15 1-7 Identifying Keys in the HOTEL and GUEST Relations . .1-16 1-8 Identifying Keys in the BILLING and RES ERVA TI ON Relations. .1-1 7 1-9 Normalizing the HOTEL Relation Creates New Relations. .1-18 1-10 Normalized HOTEL Relation . .1-18 1-11 Relations in the Overnite Hotel Reservation System . .1-23 Tables 1-1 Traditional and Relational Terminology . 1-3 1-2 Many Functions Using the Same Object . 1-3 1-3 Data Items Required by Functions . 1-4 1-4 Three Possible Records in the RATES Relation. .1-15 1-5 Data Items Become Field Names ........ .1-20 1-6 Field Names Described with Sample Data Values. .1-22 2-1 Rdb/VMS Data Types ................ .2-13 2-2 Options in the DEFINE RELATION Statement. .2-18 3-1 Rdb/VMS Data Manipulation Access Rights ... 3-4 3-2 Data Definitions Statements Controlled by Database ACL . 3-4 3-3 Data Definitions Statements Controlled by ACL for Each Relation or View in Statement . 3-5 3-4 Rdb/VMS Utility Statement Access Rights ................ 3-5 v How to Use This Manual VAX Rdb/VMS is a general purpose database management system based on the relational data model. Purpose of This Manual This manual demonstrates how to: • Design a database that is compatible with the relational data model. • Use the data definition statements of RDO, the interactive VAX Rdb/VMS utility. to translate a logical database model into a physical database. Intended Audience If you have not designed a database before, this book provides guidance on how to analyze an information management problem. You can use your analysis to design a database. This book shows all users how to use the data definition statements of RDO to implement a database design. To get the most out of this manual, you should be familiar with data processing procedures. basic database management concepts and terminology, and the VMS operating system. vii Operating System Information To verify which versions of your operating system are compatible with this ver sion of VAX RdbNMS, check the most recent copy of the following: • For the VMS operating system -- VAX/VMS Optional Software Cross Reference Table, SPD 25.99.xx • For the MicroVMS operating system -- Micro VMS Optional Software Cross Reference Table. SPD 28.99.xx Structure This manual contains four chapters. one appendix, and an index. Chapter 1 Introduces concepts of data management, data organiza tion, and the relational data model. This chapter also shows you how to design a logical database. Chapter 2 Describes how to translate the logical database into a physical database using DEFINE statements. Chapter3 Shows how to define protection for your database using the DEFINE PROTECTION statement. This chapter includes a discussion of access control lists (ACLs). Chapter4 Tells how to change or delete an existing database or elements within an existing database. Appendix A Provides sample command files for building your own version of the sample database. Index viii Related Manuals For more information on VAX Rdb/VMS, see the other manuals in this documen tation set: VAX RdbNMS Reference Manual A complete description of the statements and syntax of VAX Rdb/VMS VAX Rdb/VMS Guide to Data Manipulation A tutorial on how to use the components of VAX Rdb/VMS to retrieve, store, change, and erase data VAX Rdb/VMS Guide to Programming A tutorial on how to write high-level language programs that use VAX Rdb/VMS for database access VAX RdbNMS Guide to Database Administration and Maintenance A tutorial that explains how to use the database maintenance utilities to perform such operations as backup. recovery. restoring journals, and analyzing the database The following books provide information about the VMS operating system. VAX DATATRIEVE, and the VAX Common Data Dictionary: The VAX DAT ATRIEVE Documentation Set The VAX Common Data Dictionary Documentation Set VAX Architecture Handbook Detailed information about VAX computers and VAX data types VAX Information Architecture Summary Description A description of VAX Information Architecture component software products ix Conventions In examples, an implied carriage return occurs at the end of each line, unless oth erwise noted.