Re: Simple DB design question

2004-09-03 Thread Jeff Mathis
I've got a history table that performs a similar function. except in my 
case I can have more than 1 active row. I put in an "is_active" column 
and defined the type as a bool. an enum is actually a String in mysql, 
which i didn't want to deal with. This table has only a few thousand 
rows, so performance is not impacted at all.

jeff
sean c peters wrote:
I have some data that is stored by the year it is related to. So I have one 
table that stores the Year the data is related to, among other things. At any 
given time, 1 year is considered the 'active year', and the rest are 
considered inactive. 

The table is something like:
CREATE TABLE Data_Info
Data_Info_IDINT,
YearINT,
...
So my question is how do i best store which year is active. 2 designs come to 
mind:
1) add a column such as:
	Status	ENUM('Active', 'Inactive')
and adjust accordingly as the active year changes.

2) have a separate table:
CREATE TABLE Active_Data (
Data_Info_IDINT,
Key (Data_Info_ID),
FOREIGN KEY (Data_ID) References Data_Info(Data_Info_ID)
);
With design 1, i need to make sure that only 1 record is ever set as 'Active'.
With design 2, there will only ever be 1 record in the Active_Data table.
Neither idea seems very good to me.
Any suggestions?
thanks much
sean peters
[EMAIL PROTECTED]
mysql, query


--
Jeff Mathis, Ph.D.  505-955-1434
Prediction Company  [EMAIL PROTECTED]
525 Camino de los Marquez, Ste 6http://www.predict.com
Santa Fe, NM 87505
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Simple DB design question

2004-09-03 Thread sean c peters
I have some data that is stored by the year it is related to. So I have one 
table that stores the Year the data is related to, among other things. At any 
given time, 1 year is considered the 'active year', and the rest are 
considered inactive. 

The table is something like:
CREATE TABLE Data_Info
Data_Info_IDINT,
YearINT,
...

So my question is how do i best store which year is active. 2 designs come to 
mind:
1) add a column such as:
Status  ENUM('Active', 'Inactive')
and adjust accordingly as the active year changes.

2) have a separate table:
CREATE TABLE Active_Data (
Data_Info_IDINT,
Key (Data_Info_ID),
FOREIGN KEY (Data_ID) References Data_Info(Data_Info_ID)
);

With design 1, i need to make sure that only 1 record is ever set as 'Active'.

With design 2, there will only ever be 1 record in the Active_Data table.

Neither idea seems very good to me.

Any suggestions?

thanks much
sean peters
[EMAIL PROTECTED]

mysql, query


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]