With the help of a little spreadsheet, I generated the following SQL (untested):
CREATE TABLE MONTHS(N VARCHAR(10) NOT NULL, SHORT CHAR(3), ID TINYINT PRIMARY KEY);
Insert into months values('January', 'Jan', 1);
Insert into months values('February', 'Feb', 2);
Insert into months values('March', 'Mar', 3);
Insert into months values('April', 'Apr', 4);
Insert into months values('May', 'May', 5);
Insert into months values('June', 'Jun', 6);
Insert into months values('July', 'Jul', 7);
Insert into months values('August', 'Aug', 8);
Insert into months values('September', 'Sep', 9);
Insert into months values('October', 'Oct', 10);
Insert into months values('November', 'Nov', 11);
Insert into months values('December', 'Dec', 12);
CREATE TABLE SPEC_MONTHS(
SPECID INTEGER, MID TINYINT,
PRIMARY KEY (SPECID, MID),
FOREIGN KEY(SPECID) REFERENCES "species"(ID),
FOREIGN KEY(MID) REFERENCES MONTHS(ID)
);
insert into spec_months(select id, 1 from "species" where "FloweringJan_" = True);
insert into spec_months(select id, 2 from "species" where "FloweringFeb_" = True);
insert into spec_months(select id, 3 from "species" where "FloweringMar_" = True);
insert into spec_months(select id, 4 from "species" where "FloweringApr_" = True);
insert into spec_months(select id, 5 from "species" where "FloweringMay" = True);
insert into spec_months(select id, 6 from "species" where "FloweringJune" = True);
insert into spec_months(select id, 7 from "species" where "FloweringJuly" = True);
insert into spec_months(select id, 8 from "species" where "FloweringAug_" = True);
insert into spec_months(select id, 9 from "species" where "FloweringSep_" = True);
insert into spec_months(select id, 10 from "species" where "FloweringOct_" = True);
insert into spec_months(select id, 11 from "species" where "FloweringNov_" = True);
insert into spec_months(select id, 12 from "species" where "FloweringDec_" = True);
EDIT: fixed some issues with inconsistent field names.
My “species” table contains a numeric auto-ID column already.
EDIT2: Forgot to upload the helping spreadsheet.
Untitled.ods (18.4 KB)
The following query shows that there are 63 different flowering seasons with no season across year change, such as Nov-Jan.
SELECT DISTINCT
COALESCE ( "FloweringJan_", FALSE ) AS "JAN",
COALESCE ( "FloweringFeb_", FALSE ) AS "FEB",
COALESCE ( "FloweringMar_", FALSE ) AS "MAR",
COALESCE ( "FloweringApr_", FALSE ) AS "APR",
COALESCE ( "FloweringMay", FALSE ) AS "MAY",
COALESCE ( "FloweringJune", FALSE ) AS "JUN",
COALESCE ( "FloweringJuly", FALSE ) AS "JUL",
COALESCE ( "FloweringAug_", FALSE ) AS "AUG",
COALESCE ( "FloweringSep_", FALSE ) AS "SEP",
COALESCE ( "FloweringOct_", FALSE ) AS "OCT",
COALESCE ( "FloweringNov_", FALSE ) AS "NOV",
COALESCE ( "FloweringDec_", FALSE ) AS "DEC"
FROM "species"
WHERE "FloweringJan_" = TRUE
OR "FloweringFeb_" = TRUE
OR "FloweringMar_" = TRUE
OR "FloweringApr_" = TRUE
OR "FloweringMay" = TRUE
OR "FloweringJune" = TRUE
OR "FloweringJuly" = TRUE
OR "FloweringAug_" = TRUE
OR "FloweringSep_" = TRUE
OR "FloweringOct_" = TRUE
OR "FloweringNov_" = TRUE
OR "FloweringDec_" = TRUE
therefore we may also get a table of flowering seasons like this:
SELECT "Min"||'-'||"Max"AS "Flowering Season", "SPECID" FROM(SELECT DISTINCT "SPECID", MIN( "MID" )AS"Min", MAX( "MID" ) AS"Max" FROM "SPEC_MONTHS" GROUP BY "SPECID")
The following shrinks the data file down to 30MB:
alter table "species" drop column "FloweringJan_"
alter table "species" drop column "FloweringFeb_"
alter table "species" drop column "FloweringMar_"
alter table "species" drop column "FloweringApr_"
alter table "species" drop column "FloweringMay"
alter table "species" drop column "FloweringJune"
alter table "species" drop column "FloweringJuly"
alter table "species" drop column "FloweringAug_"
alter table "species" drop column "FloweringSep_"
alter table "species" drop column "FloweringOct_"
alter table "species" drop column "FloweringNov_"
alter table "species" drop column "FloweringDec_"
CHECKPOINT DEFRAG