Index
Turbo Database
Overview
Colum Data Types
Queries
Operators and Functions
Automatic Linking
TurboDB Tools
TurboDB Components
Frequently Asked Questions
Very often tables are linked the same way in all queries. E.g. items are
linked to the invoice they belong to, authors are linked to the books they have
written and so on. Therefore TurboDB allows you to specify different links from
one table to other tables in the table itself.
Imagine you have an invoice table where the records contain the date of the
invoice, the customer no, the invoice no and other invoice-related information.
The items are in another table that has columns like article no,
price, total amount and others. How do you link the item to the
corresponding invoice it is part of? The traditional way is to have an additional
column in the item table that designates the invoice no of the invoice the item
belongs to. Every query that respects the invoice-item relation has to contain
the following condition: ...where "ITEM.invoice no" = INVOICE.no...
Even if you can still do this the traditional way with TurboDB, the prefered way of doing it is little different. Rather than having an invoice no in the items table you would use a pointer to the item table called link field. Because the default in TurboDB is to have a (unique) record id in every table the link column in the item table just saves the record id of the invoice it belongs to. Because the definition of the link column contains the information that the values in this column point to table INVOICE, the database now knows about this relation and will by default assume it in every query. This way of linking tables has some great advantages:
You can look at link fields as an object-oriented way to work with database
tables. They do not strictly conform to the relational paradigm but bring the
feeling of pointers and references into the game. The item "knows" to which
invoice it belongs. This link is given by the nature of things and will not
probably change very often.
While link columns introduce easy 1:n relations (one invoice has many items),
this object-oriented concept makes us ask for a m:n relation i.e. a list of
pointers in one table pointing to another table. TurboDB relation fields are
the answer to this. A table containing a relation field to another table links
every record to a number of records in the other table and vice versa. Taking
again books and authors as example, inserting a relation column in the BOOK
table would take care of the fact that a book can be written by more than one
author and that one author might contribute to more than one book.
In order to profit from automatic linking you should think of adding link and
relations fields to every table you create. You will soon find it very natural
to add the linking information into the table. After all you do the same with
your Delphi, C++ and/or Java classes, don't you?
Once you have defined your links and relations, they are respected by the
database in every query. Even if you don't have any search-criteria, only
corresponding detail records will be shown for every master record. In the rare
case that you don't want this default linking you may always enter another
equate join that overrides it.
Last updated on 6/2/2000. Copyright (c) 2000 by dataWeb GmbH, Aicha, Germany. Turbo Database and TurboDB Components are products by dataWeb - the manufacturers of RAD tools for the Web. Please send your hints, questions and comments to Peter Pohmann.