14
Advanced Relational Programming

Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Advanced Relational Programming

Page 2: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Mathematics and Its Applications

Managing Editor:

M.HAZEWINKEL

Centrefor Mathematics and ComputerScience, Amsterdam,TheNetherlands

Volume 371

Page 3: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Advanced Relational Programming

by

Filippo Cacace Dipartimento di Informatica e Sis temi, Universita di Napoli Federico Il, Naples,ltaly

and

Gianfranco Lamperti Dipartimento di Elettronica per l' Automa1.ione, Universita degli Studi de Brescia, Brescia, Italy

The A/gres programme pertaining to this book is available by anonymous ftpfrom ftp.wkap.nl or by using your Web browser from URL: ftp://ftp.wkap.nVsoftwareiadvanced_relational_programmingi

SPRINGER SCIENCE+BUSINESS MEDIA, B.V.

Page 4: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

A C.I.P. Catalogue record for this book is available from the Library of Congress.

ISBN 978-94-010-3742-6 ISBN 978-94-007-0858-7 (eBook) DOI 10.1007/978-94-007-0858-7

Printed on acid-free paper

AlI Rights Reserved @ 1996 Springer Science+Business Media Dordrecht Originally published by Kluwer Academic Publishers in 1996 Softcover reprint of the hardcover 1 st edition 1996 No part of the material protected by this copyright notice may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying, recording or by any information storage and retrieval system, without written permission from the copyright owner.

Page 5: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Table of Contents

PREFACE xi

ACKNOWLEDGEMENTS xv

1. INTRODUCTION 1

1.1 Brief History of Database Technology 2

1.2 The Relational Approach 41.2.1 The Relational Application Program Interface 8

1.3 Data-Intensive Application Domains 101.3.1 Traditional Data-Intensive Applications 111.3.2 New Data-Intensive Applications 11

1.4 Requirements of New Data-Intensive Applications 16

2. OVERVIEW OF RECENT EVOLUTION IN DATABASE TECHNOLOGY 17

2.1 Semantic Data Models 17

2.2 Functional Data Models 19

2.3 Temporal Databases 20

2.4 Extended Relational Databases 222.4.1 The Extended Relational Paradigm 232.4.2 Query Languages for the Nested Relational Model 282.4.3 Nested Relational Algebra 292.4.4 Extended SQL 362.4.5 Storage Structures and Optimization Techniques 382.4.6 Extended Relational Languages and Systems 42

2.5 Deductive Databases 442.5.1 The Deductive Paradigm 452.5.2 Datalog 492.5.3 Mapping Datalog into Relational Algebra 532.5.4 Computing and Optimizing Datalog Programs 552.5.5 Extending Pure Datalog 572.5.6 Architectural Solutions: Coupling and Integration 622.5.7 Deductive Database Prototypes 68

Page 6: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

vi

2.5.8 Bibliography Notes

2.6 Object-Oriented Databases2.6.1 Essential Concepts of the Database Object-Oriented Paradigm2.6.2 Extended Object-Oriented Database Facilities2.6.3 Object-Oriented Database Systems2.6.4 Standardization of Object-Oriented Databases2.6 .5 Bibliography Notes

2.7 Active Databases2.7.1 The Active Paradigm2.7.2 Executing Active Rules2.7.3 Implementing an Active Database System2.7.4 Developing an Active Database Application2.7.5 Active Database Systems and Prototypes2.7.6 Bibliography Notes

3. THEORY OF THE NESTED RELATIONAL MODEL

3.1 The Relational Data Model

3.2 Relational Algebra3.2 .1 Selection3.2 .2 Projection3.2.3 Renaming3.2.4 Join3.2.5 Set Theoretic Operations3.2.6 Expressions

3.3 Relational Calculus

3.4 Nested Relational Data Model

3.5 Extended Relational Algebra3.5.1 Extension of Set Operations3.5.2 Nest and Unnest3.5.3 Operators Requiring a Predicate3.5.4 Extended Projection, Set Theoretic Operations, and Selection3.5.5 Nesting Operators

3.6 Equivalence or Extended Relational Algebra Expressions3.6.1 A Minimal Set of Operators for ERA3.6.2 Equivalence of Expressions in ERA3.6.3 Distributivity of Binary Operators in Nest and Unnest

3.7 Extended Relational Calculus

3.8 Expressive Power: Comparing Algebra and Calculus

3.9 Taxonomy or Nested Relations3.9.1 Nested flat relations3.9.2 Permutable nested relations3.9.3 Partitioned Normal Form Relations

3.10 Further Extensions to the Nested Relational Model3.10.1 Further Extensions to the Data Model

Table of Contents

70

717382929698

99101103106109110112

114

114

116117117117118118118

120

123

126126126128129134

136136136139

140

141

144145146147

148148

Page 7: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Table ofContents

3.10.2 Further Extensionsto Relational Algebra

vii

151

4. ALGRES, AN EXTENDED RELATIONAL DATABASE PROGRAMMINGLANGUAGE 152

4.1 A Tour of Aigres4.1.1 The UniversitySupport System4.1.2 The IndustrialMap System4.1.3 Other RelevantFeaturesof Algres

4.2 Rationale of Aigres Design

5. PROGRAMMING IN ALGRES

5.1 Constants, Identifiers, and Objects5.1.1 Simple Constants5.1.2 ComplexConstants5.1.3 Empty Collections5.1.4 Identifiers5.1.5 Definitionof Objects

5.2 Groups and Persistency5.2.1 Creating Groups and PersistentObjects5.2.2 Virtual Group and Transactions5.2.3 DestroyingPersistentObjects and Groups5.2.4 ManipulatingPersistentObjectsUsing Transactions

5.3 Operations5.3.1 Set Operations5.3.2 Classic Unary Operations5.3.3 QuantifierOperations5.3.4 Operationsof SchemaManipulation5.3.5 Classic binary operations5.3.6 Type Transformation5.3.7 Tuple Functions5.3.8 ConditionalExpression5.3.9 Nestingand Unnesting5.3.10 Closure (Fixed Point Operation)5.3.11 SimpleFunctions5.3.12 AggregateFunctions5.3.13 FunctionalExpressions5.3.14 Assignment

5.4 The Quantification Mechanism5.4.1 Algres as FunctionalLanguage5.4.2 The UniversalTree5.4.3 The ConsistencyRules5.4.4 Environment5.4.5 The external Quantification

5.5 Input-Output5.5.1 Output5.5.2 Input

5.6 Control structures and blocks

152153179187

201

205

205205206207207207

210212212214214

217217221229231232235238243244249251252255257

257257258260262266

267268270

272

Page 8: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

viii

5.7 Subprograms5.7.1 Subfunctions5.7.2 Procedures

5.8 Links

5.9 Built in functions5.9.1 CARD5.9.2 CONTENT5.9.3 FIRST and LAST5.9.4 ORD5.9.5 OCCURRENCE5.9.60CC5.9.7 POS5.9.8 MATCH

5.10 Program Structure

Table ofContents

275277278

281

286287287288288289289290290

292

6. ALICE,THE APPLICATION PROGRAMINTERFACEOF ALGRES 294

6.1 A Tour of Alice 294

6.2 Guidelines for Writing Alice Programs 3046.2.1 The Transparency Principle 3046.2.2The HomogeneityPrinciple 3056.2.3 The Program Instance Principle 3066.2.4The Virtual InterpreterPrinciple 3086.2.5 The Constant Principle 3116.2.6 The Identifier Principle 3126.2.7 The Algebraic Principle 3136.2.8 The FunctionalPrinciple 3166.2.9 The Full ParameterizationPrinciple 3186.2.10 The Algres to C Data MappingPrinciple 3186.2.11 Flexibilityof GETOBJ 3206.2.12The C to Algres Data MappingPrinciple 322

6.3 Programming in Alice 3226.3.1 Summaryof Guidelines 3236.3.2 Alice Operators 3246.3.3 Virtual Interpreter Operators 3246.3.4 Full Parameterization Operator 3266.3.5 Algres to C Mapping Operator 3266.3.6 C to Algres Mapping Operator 329

7. ALGRAPH, THE GRAPHICALINTERFACEOF ALGRES 331

7.1 Graphical Display 3317.1.1 Communication Panel 3327.1.2 CommandPanel 3347.1.3 InstancePanel 335

7.2 Graphical Read 3367.2.1 SchemaPanel 3367.2.2CommandPanel 3377.2.3 InstancePanel 337

Page 9: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Table ofContents ix

7.3 Motif Interface for Input-Output 3417.3.1 Motif Display 3427.3.2 Motif Read 3437.3.3 Filtering Instance Files 343

7.4 Schema Editor 3457.4.1 Schema Panel 3457.4.2 Scroll Panel 3457.4.3 CommandPanel 345

APPENDIX A: SYNTAX OF ALGRES 356

APPENDIX B: SYNTAX OF ALICE OPERATORS 361

APPENDIX C: ALGRES AND ALICE KEYWORDS 363

APPENDIX D: INSTALLING AND USING THE ALGRES SYSTEM 366

Getting a Free Copy of the Algres System 366

Installing Algres 366

Using A1gres Commands 368

Compiling and Executing Algres Programs 369

Compiling and Executing Alice Applications 370

Editing Algres Objects 371

BIBLIOGRAPHY 373

INDEX 391

Page 10: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Preface

Database programming is the process of developing data-intensive applications whichdemand the access to large amounts of structured, persistent data. The primary toolrequired for implementing such applications is a database programming language,namely a formal language which is specialized in the definition and manipulation ofrelevant large-scale data. As such, a database programming language is expected toprovide high-level data modeling capabilities as well as a variety of constructs whichfacilitate the handling of the specified data .

In this perspective, the aim of this book is: (i) to present the recent advances indatabase technology from the viewpoint of the novel database paradigms proposed forthe development of advanced, non-standard, data-intensive applications, (ii) to focusspecifically on the relational approach, with considerable emphasis on the extensionsproposed in the last decade, and (iii) to describe the extended relational databaselanguage Algres which is primarily the outcome of research work conducted by theauthors in cooperation with a large number of other colleagues and students.

Furthermore, in order to put the concepts presented in the book into practice, thereader is invited to experiment with the Algres system, a free copy of which can berequested from Kluwer Academic Publishers, or directly from the authors.

Depending on the specific interest and background of the reader, the book can serveeither : (1) to overview recent trends in databases, (2) to introduce in more detail theconcepts and theory of the nested relational model , or (3) to present a completeadvanced relational language which can be freely used for experimental purposes withinacademic and research frameworks.

This book is aimed at readers who already have some familiarity with databasesystem concepts and programming languages. As such, the book is appropriate for avariety of categories of people, including : (l) either undergraduate or masters levelstudents following advanced database courses, (2) graduate research students or researchstaff who are interested in the recent advances in database technology, (3) data-intensiveapplication developers who are motivated to know about novel database technologywhich can be better exploited for their own application area, and (4) researchers in thedatabase programming languages field who can benefit from the prototyping of novel .paradigms on top of an extended virtual relational machine, rather than on top of atraditional commercial relational database system.

This book is conceptually divided into three parts which can be read independentlyby different readers. The first two chapters motivate the need for advanced databaseprogramming paradigms and present a non-exhaustive overview of the recent trends indatabase technology. In the choice of arguments we have concentrated our attention onthose novel database systems which are somehow related to the extended relationalapproach. The second part, which consists of Chapter 3 together with Section 2.4,

Page 11: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

xii Preface

I. IntroductionPart I 2. Overview of Recent Evolution in Database Technology

2.4 Extended Relational Databases

Figure-i The conceptual view of the book

Extended Relational Databases, of the overview, is mainly devoted to the presentationof the concepts and theory of the nested relational model. Finally, the third part, namelyChapters 4 through 7, presents exhaustively the extended relational databaseprogramming language Algres.

Our view of the book can be graphically represented by the picture displayed inFigure-i, Observe that Part II is viewed as a refinement of Part I (more precisely, atheoretical basis for the concepts introduced in Section 2.4), while Part ill is aninstantiation of the theory presented in Part II, namely an actual extended relationalprogramming language.

The table shown in Figure-ii represents a sort of roadmap of the book for threehypothetical categories of readers.

The whole set of chapters is organized as follows. Chapter I, Introduction, motivatesthe need for advanced database programming paradigms in the context of novel non­traditional data-intensive application domains. Specifically, after a brief history ofdatabase technology, an informal idea of the relational approach is given. Afterwards, anumber of emerging new database application areas are described, and thecorresponding requirements for the database technology are specified.

Chapter 2, Overview of Recent Evolution in Database Technology, provides anoverview of the most significant database programming paradigms which have beenproposed in the last decade. This includes semantic data models, functional data models,temporal databases, extended relational databases, deductive databases, object-orienteddatabases, and active databases. The first three paradigms are only mentioned, while theothers are introduced in more detail, even though all of them presented informally.

Chapter 3, Theory of the Extended Relational Model, focuses on the concepts of therelational model and relevant extensions, with major emphasis on the nested relational

Part I Part II Part IIII 2 3 4 5 6 7 ADD.

Recent trend ofdatabase technology x xExtended relational model and languages 2.4 x xExperimentation ofan extended relational system x x x x x

Figure ii Roadmap for three different categories of readers

Page 12: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Preface xiii

model. This emphasis serves to prepare the reader for the subsequent part of the bookwhich is completely devoted to the presentation of the extended relational databaseprogramming language Algres.

Chapter 4, Algres, an Extended Relational Database Programming Language,provides an introduction to the Algres language through a tutorial example. The mainconcepts of the language, such as the modeling of complex objects, the extensions oftraditional relational operations, the new operations of nest and unnest, and thetransitive closure operator are introduced using examples relevant to different problems.The most recent extensions, including subprograms, control structures, recursion, links,and persistency, are discussed at the end of the chapter.

Chapter 5, Programming in Algres, provides a systematic presentation of the Algreslanguage in terms of syntax and semantics of the operations informally introduced inChapter 4.

Chapter 6, Alice, the Application Program Interface of Algres, covers thepresentation of the Alice language, a superset of C and Algres languages, which allowsthe linking of applications written in the C general-purpose language (or, indirectly,whatever programming language which can be interfaced to C) with Algres.

Chapter 7, Algraph, the Graphical Interface ofAlgres, is devoted to the presentationof the graphical interface of Algres which allows the presentation and the editing ofcomplex objects.

The body of the book terminates with four appendixes, the first three of which arefocused on the whole syntax of Algres and Alice. The last appendix, Installing andUsing the Algres System, is intended for those readers who are interested inexperimenting with the Algres system. To this end, the appendix provides guidelines forgetting a free copy of the whole Algres system, and for installing and using it within theUnix operating system.

We apologize to those who find their favorite topics missing, and to those authorswhose work has been represented poorly or not at all.

Comments , corrections, suggestions, and requests are appreciated and should be sentto the authors:

[email protected]@bsing.ing .unibs .it.

Page 13: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

Acknowledgements

We should like to take this opportunity to thank the people with whom we have beenworking in the research area of formal languages and database systems over the years,and who have influenced us in various ways; in alphabetical order these are StefanoCeri, Stefano Crespi Reghizzi, Letizia Tanca, and Roberto Zicari.

This book is primarily the outcome of research work conducted by the authors incooperation with other colleagues of the Politecnico di Milano and TXT IngegneriaInformatica. The focus of this research has been the Algres project, which was started in1985 by Stefano Ceri, Stefano Crespi Reghizzi, and Luigi Lavazza, as the continuationof previous research on the use of relational techniques for program constructionenvironments. Later, Filippo Cacace, Carlo Cappelli, Gianfranco Lamperti, LetiziaTanca, and Roberto Zicari joined the team of Algres designers .

Algres was developed through the effort of numerous master students of thePolitecnico di Milano, including S. Aliverti, M. Allamprese, A. Alleva, M. Alleva, M.Antonetti, G. Bossi, P. Buda, F. Businelli, M. Cavanesi, F. Cesani, P. Dotti, L. Drusin,M. Ferrario, M. Giudici, D. Milani, R. Malloggi, D. Mapelli , D. Moggia, P. Nasi , M.Orlando, A. Pastori, A. Patriarca, M. Patriarca, G. Pisani, G. Redemagni, M. Riva, G.Turani, P. Vagnozzi, L. Vitali, O. Zaffaroni, and A. Zanettini. To all of them we aredeeply indebted.

Stefano Crespi Reghizzi deserves special recognition for the idea of the book, for theabundant material provided to the authors, and for the special commitment to Algres hehas shown continuously over several years .

We should like to thank TXT Ingegneria Informatica for the support given in thedevelopment of Algres . Specifically we should like to mention Carlo Cappelli, AlbertoDapra, Andrea Di Maio, and Luigi Lavazza.

Algres development was partially supported by Esprit projects Meteor and Stretch,and by the Italian CNR and MURST.

It is with particular pleasure that we express our affectionate and deeply-felt gratitudeto Ben Mulvihill, who gave the manuscript meticulous attention, and who has made anenormous contribution to the clarity, accuracy, and completeness of the finished text; hisline-by-line analysis and comments have resulted in a large number of importantcorrections and improvements.

We are also most grateful to all the friends who have encouraged us in writing thebook, including Pietro Baroni, Bruno Berardi, Terzo Betella, Andrea Bobbio, RiccardoCassinis, Carlo Colombo, Giuliano Cordioli, Max De Carli, Marino Faifer, Luisa Faletti,Rosanna Fogliata, Bruno Fontana, Paolo Gabusi, Luciano Galli , Luciano Gambassa,Alfonso Gerevini, Giovanni Giuffrida, 'Luigi Gregori, Giovanni Guida, GiacomoManenti, Marcello Peracchi, Giuseppe Pozzi, Silvio Mori , Stefano Paraboschi, Antonio

Page 14: Advanced Relational Programming - Springer978-94-007-0858-7/1.pdf · database technology from the viewpoint of the novel database paradigms proposed for the development of advanced,

xvi Acknowledgements

Patarini, Alessandro Rizzi, Caterina Saraceno, Anna Torri, Paola Vesentini, and MarinaZanella.

Thanks to the anonymous reviewers whose comments and suggestions have greatlyimproved the content and presentation of the book.

Finally, we must acknowledge our debt to the people of Kluwer Academic Publishersfor the professional handling of the project. In particular we should like to thankAngelique Hempel, Anneke Pot, and Paul Roos for the unfailing courtesy and patiencethat distinguish editors from authors.