Re: A database design question
From: Bjørge Sæther (bjorge_at_hahaha_itte.no)
Date: 10/23/03
- Next message: Bjørge Sæther: "Re: selection/highlighting behavior in TListView"
- Previous message: J French: "Re: TFileSream Help Needed."
- In reply to: Stark: "A database design question"
- Next in thread: Stark: "Re: A database design question"
- Reply: Stark: "Re: A database design question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Oct 2003 09:37:54 +0200
"Stark" <starkwedder@virgilio.it> skrev i melding
news:cWwlb.331309$R32.10926952@news2.tin.it...
> To put my question, I find it easier to give you an example:
> Say I have a BOOKS table; each record represents a book and stores info
> such as author, library, and so on..
> Take the author field (but the same applies to library): I have two
choices
> to represent it: 1) either I directly store the AUTHOR NAME, or 2) I store
> an AUTHOR ID, linked to another table (AUTHORS) where the names are
stored.
>
> I thought option 1 to be the soundest choice, since it gives greater
> flexibility (for instance, it allows changes in the author names with no
> impact on the BOOKS table).
> Then I found there are disadvantages also. Apart from the difficulty in
> keeping syncronized BOOKS and AUTHORS, the major thing is the
impossibility
> to define a BOOKS table index on the Author Name (I found I can define an
> authorName field in books as a lookup field, but I cannot define an index
on
> it. BTW I am using dBase, if this makes a difference..)
>
> Can annyone help with some thoughts or advice ?
First of all, you need to define whether Author is a "meaningful value" or
just info. If your application "does things with Authors", then you probably
should keep Authors in a separate table. If you're gonna handle more
authors, you have more choices:
- Use ID_AUTH_1, ID_AUTH_2 .. ID_AUTH_N fields, which makes lookups possible
- List ID_AUTHOR's commaseparated in a string field, which breaks your
lookup functionality and requires you to write the lookup code by hand
- Use a rendundant (superfluous) field in addition to ID_AUTHORS:
NAME_AUTHORS, which is updated whenever ID's are changed
To be able to sort on Author's Name, you would need to add the rendundant
AUTHOR_NAME field, this requires some functionality to update BOOKS table
whenever a name is changed in AUTHORS table.
The other option is using SQL for ordering the items. Then you need no index
(but it may be slow).
Or, you could of course use a TClien tDataSet if you have Delphi
Enterprise/Studio. Then all boks data will be loaded into memory, and
sorting is no problem.
-- Regards, Bjørge Sæther bjorge@haha_itte.no ------------------------------------- I'll not spend any money on American Software products until armed forces are out of Iraq.
- Next message: Bjørge Sæther: "Re: selection/highlighting behavior in TListView"
- Previous message: J French: "Re: TFileSream Help Needed."
- In reply to: Stark: "A database design question"
- Next in thread: Stark: "Re: A database design question"
- Reply: Stark: "Re: A database design question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|