| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

05-21-08, 09:34
|
|
Registered User
|
|
Join Date: Jun 2005
Posts: 319
|
|
|
looking for best practices solution (aka help settle a bet)
|
|
Ok so there has been some discussion at work regarding the best way to tackle this solution.
For a given Person...
Option A
PERSON
*PERSON_ID INT
PERMISSION_START_DATE SMALLDATETIME --START DATE PERMISSION CAN START
PERMISSION_END_DATE SMALLDATETIME --END DATE WHEN PERMISSION IS NO LONGER VALID
:
About 20 other columns unrelated to this question
Option B
PERSON
*PERSON_ID INT
PERMISSION_STATUS TINYINT -- 0: INACTIVE | 1: ACTIVE - ALWAYS | 2: ACTIVE - DATEBOUND (USE TWO DATE COLUMNS BELOW)
PERMISSION_START_DATE SMALLDATETIME
PERMISSION_END_DATE SMALLDATETIME
:
About 20 other columns unrelated to this question
Option C
{something different} --perhaps Option B but normalized
My peer wants to set the date values in Option A by setting start = 0 and end = 65535 (which I guess is min_date '1/1/1900' and max_date '6/6/2079')
I am opting for Option B since I don't want garbage dates cluttering our system since I think it reflects poorly when reports are generated or when users need to set explicit dates since we either show them these bogus dates or the application needs to interpret the bogus dates as an Always On status.
Thoughts?
|
Last edited by Gagnon; 05-21-08 at 10:52.
|

05-21-08, 10:04
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
your peer thinks 65535 is a valid SMALLDATETIME? it's a valid INTEGER, that's all
if a "thing" (you didn't mention what this table is about) can be inactive, always active, or datebound, then option A fails because it doesn't allow for those statuses
what do you do about a thing which has several valid datebound ranges?
by the way, a very common and practical way to record "bogus dates" is with NULL
|
|

05-21-08, 10:16
|
|
World Class Flame Warrior
|
|
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
|
|
|
|
Quote:
|
Originally Posted by r937
by the way, a very common and practical way to record "bogus dates" is with NULL
|
Gasp! Sir, I shall report you to Fabian! 
__________________
If it's not practically useful, then it's practically useless.
blindman
www.chess.com: "sqlblindman"
|
|

05-21-08, 10:20
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
|
|

05-21-08, 10:41
|
|
Registered User
|
|
Join Date: Jun 2005
Posts: 319
|
|
Not sure if it matters but the "thing" in question is a person record, this is a particular type of person - again should be mostly irrelevant.
I will make it less generic in the original post (assuming I can still edit it).
|
|

05-21-08, 11:25
|
|
Registered User
|
|
Join Date: Jun 2005
Posts: 319
|
|
Quote:
|
Originally Posted by r937
your peer thinks 65535 is a valid SMALLDATETIME? it's a valid INTEGER, that's all
|
Well in MSFT SQL Server it casts it to the dates I mentioned earlier.
So everyone is on board that storing MIN/MAX dates in date columns is a bad implementation/design, correct?
|
|

05-21-08, 11:33
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
Quote:
|
Originally Posted by Gagnon
Well in MSFT SQL Server it casts it to the dates I mentioned earlier.
|
you did not mention this earlier
|
|

05-21-08, 11:33
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
Quote:
|
Originally Posted by Gagnon
So everyone is on board that storing MIN/MAX dates in date columns is a bad implementation/design, correct?
|
no, i'm not
|
|

05-21-08, 11:37
|
|
Registered User
|
|
Join Date: Jun 2005
Posts: 319
|
|
Quote:
|
Originally Posted by r937
you did not mention this earlier
|
try reading my post like this:
[beginning sentence] - to the dates I mentioned earlier
|
|

05-21-08, 11:38
|
|
Registered User
|
|
Join Date: Jun 2005
Posts: 319
|
|
Quote:
|
Originally Posted by r937
no, i'm not
|
So you often (or even sometimes) have date columns that show dates such as:
1/1/1900
and
6/6/2079?
Do you interpret these differently (translate the values to something more meaningful) on the UI or in reports?
|
Last edited by Gagnon; 05-21-08 at 11:45.
|

05-21-08, 11:47
|
|
World Class Flame Warrior
|
|
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
|
|
Quote:
|
Originally Posted by r937
if you can find him
|
Code:
begin tran
set @FPascal = null
commit
__________________
If it's not practically useful, then it's practically useless.
blindman
www.chess.com: "sqlblindman"
|
|

05-21-08, 11:48
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
Why have a status when you can easily find out whether it's active or not based on the start and end dates?
|
|

05-21-08, 11:59
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
Quote:
|
Originally Posted by georgev
Why have a status when you can easily find out whether it's active or not based on the start and end dates?
|
because you need a status to distinguish NULL/NULL meaning inactive, versus NULL/NULL meaning active always
|
|

05-21-08, 12:02
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
Quote:
|
Originally Posted by Gagnon
So you often (or even sometimes) have date columns that show dates such as:
1/1/1900
and
6/6/2079?
|
i would never, never (never!!!) have date columns that show dates in that format
sheesh!!!
BTW, my "no, i'm not" was in response to "is everyone on board that..."
try reading my posts from [quoted stuff] - [end]

|
|

05-21-08, 12:06
|
|
Registered User
|
|
Join Date: Jun 2005
Posts: 319
|
|
Quote:
|
Originally Posted by r937
i would never, never (never!!!) have date columns that show dates in that format
sheesh!!!
BTW, my "no, i'm not" was in response to "is everyone on board that..."
try reading my posts from [quoted stuff] - [end]

|
eh I guess someone misinterpreted a double negative
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|