Base Tutorial: from Newbie to Advocate in a One, Two
Total Page:16
File Type:pdf, Size:1020Kb
Base Tutorial: From Newbie to Advocate in a one, two... three! BASE TUTORIAL: From Newbie to Advocate in a one, two... three! Step-by-step guide to producing fairly sophisticated database applications with OpenOffice.org Base, from initial problem to final product complete with forms and reports. by Mariano Casanova Base Tutorial: From Newbie to Advocate in a one, two... three! By Mariano Casanova Copyright © 2010 Mariano Casanova. All rights reserved. First Edition: August 2010 Second Edition: September 2010 All names of products and companies mentioned in this text are the trademark of their respective owners and are mentioned here with no intention of infringement and for the benefit of those respective owners. Please note that the author can not provide software support. Please contact the appropriate software developers of Base or HSQL at: www.openoffice.org and www.hsqldb.org or their fantastic fan base and forum experts. The author has taken every precaution possible to ensure the correctness and appropriateness of the information provided in this text, including the testing of the code supplied. However, due to possible human or mechanical error from the sources, the constant changing and evolution of the software described and known and unknown issues in the code, its functioning and compatibility, the author can assume no responsibility for er- rors or omissions or for damages resulting from the use of the information provided here. The author does not guarantee the accuracy, adequacy or completeness of this information and shall not be liable to any person, legal or natural, with respect to any loss or damage caused or allegedly caused directly or indirectly by the use of such information, including but not limited to, business interruption, loss of profits or loss of data. The information is provided "as is" with no warranties whatso- ever of its appropriateness or fitness for any purpose. You use this information at your own risk. This digital edition can be distributed under the terms of the Creative Commons Attribution Non-Commercial Share Alike license, as described in: License, full text: http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode License, summary: http://creativecommons.org/licenses/by-nc-sa/3.0/ You can copy this electronic file and distribute this electronic file with no limitation for all non-commercial use. You can ad- apt, expand or translate this work as long as you: a) Attribute the work by providing the name of the initial author and a link to the original work or, if such link is not available, a reference to the source of your copy of the original work. Your attribu- tion must not suggest that the initial author endorses you or your use of the work. b) Clearly state the nature and scope of your contribution to the work. c) Distribute this work under the same or similar license and ensure that all derivatives will also be non-commercial in nature. You can not use this work or its derivatives for commercial purposes. Base Tutorial OOo. To everyone involved in the creation, distribution and documentation of free and open software And in particular to the developers, writers and administrators at OpenOffice.org ~Thanks! FROM NEWBIE TO ADVOCATE IN A ONE, TWO... THREE! Content overview: Part I: Things you need to know before you create a database with Base. Where we introduce this tutorial and its scope. We start by analyzing what a database is and describe its different components: Tables, relationships, primary and foreign keys, columns, column attributes, deletion attributes and relationship cardinalities and finally we provide a definition of database and Base database. We later comment on forms and reports and on modeling data and goals of proper design, after which we provide an over- view of UML diagrams to use as a visual vocabulary. We then summarily review phases in database design and the importance of Normal Form. We also review First, Second and Third normal forms and how they aid in class extraction. After this we review the way that Base records attributes and the nature of the variables it uses, analyzing text vari- ables, numeric variables, date and time variables and object variables and how choosing them properly will affect the performance of a Base application. Part II: Things you need to do before you code a database with Base. Where we offer a real case example and, using the elements presented in part I, we start with a problem and end with a database design. We cover class formation, class extrac- tion, the importance of atomization and descriptors. We apply normalization and other tools to decide on data structure and finally come up with a complete UML diagram of our database. We then stress the importance of using auxiliary elements like a Variables Definition List for the aid they provide in coding our application with Base. After this we analyze the problem of duplicity of roles in order to introduce the concept of super-class formation. We then analyze the forms and reports that we will use in conjunction with the design we have produced and describe the kind of features we will want them to have. Now that we understand how to design our tables, its connections, forms and reports, and what do the options that Base offers mean, we are ready to sit down in front of Base and start coding our database. Part III: Things you need to do while coding a database with Base. Where we describe how to use Base to create the database it took us so long to design, complete with forms and reports. We star by analyzing the setup and explain how to use SQL commands for the creation of tables and relationships, analyzing the “Create Table” and “Constraint” instructions in detail. We also review how to read their descriptions when consulting the Wiki or other sources. Then we describe in depth how to create forms to populate our tables and how to use radio buttons, sub-forms, list boxes and other widgets to simplify data entry. We later take our time to analyze the “Select” command to produce queries and extract information from our data and finally explain in detail how to produce the reports using both the Report Wizard and the SUN Report Builder. i BASE TUTORIAL Table of Contents Introduction:....................................................................................................................v Acknowledgments.........................................................................................................vii Part I: Things you need to know before you create a database with Base. Chapter 1..............................................................................................................................3 Introduction to databases.................................................................................................3 Anatomy of a database: Tables, attributes and relationships......................................3 Establishing relationships within tables.....................................................................7 Cardinality and optionality of a relationship..............................................................8 Managing relationships with column and delete options.........................................10 A definition of database and database design................................................................11 Talking about forms and reports....................................................................................12 Modeling data and goals of proper design....................................................................13 Visual vocabulary..........................................................................................................14 Phases in database design..............................................................................................16 Chapter 2............................................................................................................................19 Getting into normal form..............................................................................................19 First normal form......................................................................................................20 Second normal form.................................................................................................20 Third normal form....................................................................................................21 Aiming for simplicity....................................................................................................23 Chapter 3............................................................................................................................25 Recording attributes: Are you my variable?..................................................................25 Why is all this information relevant?............................................................................30 On logical Names and Physical Names........................................................................31 Part II: Things you need to do before you code a database with Base. Chapter 4............................................................................................................................35 Let's get real!.................................................................................................................35 Case Example: Now we need a problem.......................................................................35 Possible solution............................................................................................................39