Subject | Re: [Firebird-general] Re: Dropdown list for variable domain |
---|---|
Author | Robert Ritter |
Post date | 2005-04-11T15:01:27Z |
Adam - Thanks for responding. We're getting closer. The problem now is that I'd like to do all this using IBEasy+ and what you describe is for user written code. I probably need to come up to speed but for now I'm stuck with the IBEasy+ user interface. It seems to do everything I need ( almost ). I have the OBSTRUCTIONS_TYPE table and reference it in the table structure for the OBS_TYPE column which forces the correct input to be entered, BUT I don't want any data entered, just selected from a drop down. Thanks again, Bob Ritter
Adam <s3057043@...> wrote:
Hi Rob,
What you seem to be describing is the perfect candidate for database
normalisation.
If I understand your problem right, you have something like this:
TableA
(
ID,
Name,
Address,
Obstruction
)
Now you are running into trouble because you have defined Obstruction
as a varchar but you want to ensure that only particular values are
accepted, like "Tower" and "Building", but if someone enters "Henry",
you don't want that to go through.
The best way to do this is to define a table with an exhaustive list
of valid obstructions, and have your table(s) link to this via a
foreign key:
Obstructions
(
ID,
Name
)
TableA
(
ID,
Name,
Address,
ObstructionsID
)
There are several problems with having it as a varchar. Firstly it
normally takes up more room to store. Secondly, you risk dirty data
slipping in if there is a bug in your user interface.
Your dropdown box source is now pretty simple.
Select ID, Name
from Obstructions
order by Name
When you declare the foreign key, you can define what you want to
happen if an obstruction is deleted. For example, if you delete
"Tower", do you want all the records in TableA which have the
obstruction "Tower" to be deleted, or do you want the Obstruction set
to null, or do you want the delete to fail.
I hope that helps.
Adam.
Community email addresses:
Post message: Firebird-general@yahoogroups.com
Subscribe: Firebird-general-subscribe@yahoogroups.com
Unsubscribe: Firebird-general-unsubscribe@yahoogroups.com
List owner: Firebird-general-owner@yahoogroups.com
Shortcut URL to this page:
http://www.yahoogroups.com/community/Firebird-general
Yahoo! Groups Links
---------------------------------
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
[Non-text portions of this message have been removed]
Adam <s3057043@...> wrote:
Hi Rob,
What you seem to be describing is the perfect candidate for database
normalisation.
If I understand your problem right, you have something like this:
TableA
(
ID,
Name,
Address,
Obstruction
)
Now you are running into trouble because you have defined Obstruction
as a varchar but you want to ensure that only particular values are
accepted, like "Tower" and "Building", but if someone enters "Henry",
you don't want that to go through.
The best way to do this is to define a table with an exhaustive list
of valid obstructions, and have your table(s) link to this via a
foreign key:
Obstructions
(
ID,
Name
)
TableA
(
ID,
Name,
Address,
ObstructionsID
)
There are several problems with having it as a varchar. Firstly it
normally takes up more room to store. Secondly, you risk dirty data
slipping in if there is a bug in your user interface.
Your dropdown box source is now pretty simple.
Select ID, Name
from Obstructions
order by Name
When you declare the foreign key, you can define what you want to
happen if an obstruction is deleted. For example, if you delete
"Tower", do you want all the records in TableA which have the
obstruction "Tower" to be deleted, or do you want the Obstruction set
to null, or do you want the delete to fail.
I hope that helps.
Adam.
Community email addresses:
Post message: Firebird-general@yahoogroups.com
Subscribe: Firebird-general-subscribe@yahoogroups.com
Unsubscribe: Firebird-general-unsubscribe@yahoogroups.com
List owner: Firebird-general-owner@yahoogroups.com
Shortcut URL to this page:
http://www.yahoogroups.com/community/Firebird-general
Yahoo! Groups Links
---------------------------------
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
[Non-text portions of this message have been removed]