I would like to have some fields of a table with specific values, for instance: “male”/“female”, or the months of the year or the days of the month.
What is the procedure in base?
Thank you
I would like to have some fields of a table with specific values, for instance: “male”/“female”, or the months of the year or the days of the month.
What is the procedure in base?
Thank you
For a field, which should show the gender, I would prefer a varchar-field for only 1 character (“m”,“f”,…). I would create a second table “gender”, which has the same content as primary key. So I could add fields in this second table for “gender” (Varchar 20), “salutation” (Varchar 20) …
Fields, which should only show the month or the days of a month I would create with a tiny integer field. But you couldn’t set the range for this field automatically to 1 to 12 (for month). Range will be from -128 up to 127.
I use boolean fields for male/female with a pair of option buttons in the input forms. I use date fields for anything related to dates. From a date you can derive the year, month, day and weekday.
Hi Villeroy,
with boolean you could only choose 2 types. What is with “non-binary”? I use this field also for something like “company” …
Regards
Robert
Thank you all. I set a table apart for the months, but I also found that the forms allow setting some default values (option button), so I could set male, female, other.
HSQL:
ALTER TABLE TBL ADD CONSTRAINT "MonthNumber" CHECK (M BETWEEN 1 AND 12);
Anyhow, a full date field is more practical.
Added this to next Base Handbuch.
You are right, date fields will be better than separate numeric fields for days and months.
HSQL1 documentation:
ALTER TABLE ADD [CONSTRAINT ]
CHECK ();
Adds a check constraint to the table. In the current version, a check constraint can reference only the row being inserted or updated.
So we can not check duplicates or min/max across the whole table.
Nother valid sample:
ALTER TABLE TBL ADD CONSTRAINT "TimeSpan" CHECK ("T1" <= "T2")