gettingstarted
[Top] [All Lists]

Re: What is a database record?

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: What is a database record?
From: Phil Mobley <phil at mobleybros dot com>
Date: Tue, 28 Dec 2004 12:37:21 -0800
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <8CCA3D6A-5902-11D9-977D-003065D91F8C at MacDialUp dot com>
On Dec 28, 2004, at 10:59 AM, Wayne Dreier wrote:

As I understand database structure, a record consists of a single row of fields (columns). If this statement is correct, then how do I deal with a record that needs to consist of multiple rows of those fields?

Stated another way, in my app which keeps track of research, I will search and need to record data about family units from certain sources. How would I go about retrieving multiple rows of data as a single record?

What you do is have two different tables.

Here is an example:

You need to keep track of your product serial numbers. Well a single person can own more than one license or even multiple products. You don't want to have all of the contact information for the person in the registered products table, because (a) what if the contact info changes, and (b) it takes up too much space (duplication of data).

You have a single table called 'Person' table contains a unique identifier for each person (if you are using the RB DB, you can use the '_rowid' column). Then in the 'Serials' table, have a column 'person_id' which is the same unique identifier used in the 'Person' table.

Then to get all of the serial numbers registered to anyone who's last name is 'Smith', here is the SQL (I am pretty sure this syntax is correct and Will can correct me if I am wrong):

SELECT a.snumber FROM Serials A, Person P WHERE a.person_id=p._rowid AND p.last_name='Smith'

This is called a Join where you take conditions from two tables to generate the search results.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>