This is a discussion on field features... within the MySQL forums, part of the Database Server Software category; --> I have a table A with two fields, length and temperature, eg. Both fields have some charateristics, like: field ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have a table A with two fields, length and temperature, eg. Both fields have some charateristics, like: field length to use when printing, units (meters, degrees) maximum value minimum value default value etc etc. How would I describe such a situation in MySQL ? I was thinking of making another table B of "characterisctics" and then connecting fields in table A to records in table B. Can that be done in MySQL ? |
| ||||
| On Tue, 11 Dec 2007 11:08:00 +0100, Osiris <et57@hotmail.com> wrote: > I have a table A with two fields, length and temperature, eg. > Both fields have some charateristics, like: > > field length to use when printing, Nothing to do with MySQL. > units (meters, degrees) Again, nothing to do with MySQL, or the value in the columns (just append it if needed). > maximum value > minimum value Unless you can whitelist all the values (foreign key constraint on another field/table holding all possible values for the column, you'll have to use triggers. > default value Default is easily given as a field property. > How would I describe such a situation in MySQL ? > I was thinking of making another table B of "characterisctics" and then > connecting fields in table A to records in table B. > Can that be done in MySQL ? You can store some information about a field in another table. Most of what I think you want cannot be done automatically with MySQL though, you'll have to use the logic either in the script/application using MySQL, or be prepared to write some very long queries, with dozens of if-statemenst/joins for each field just to get the right 'representation'. For more control over what goes into a field/row or gets deleted, you can use triggers and/or foreign key constraints. There is no such thing for selects though. -- Rik Wasmus |