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.

 
Go Back  dBforums > General > Database Concepts & Design > looking for best practices solution (aka help settle a bet)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-08, 09:34
Gagnon Gagnon is offline
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.
Reply With Quote
  #2 (permalink)  
Old 05-21-08, 10:04
r937 r937 is offline
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-21-08, 10:16
blindman blindman is offline
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"
Reply With Quote
  #4 (permalink)  
Old 05-21-08, 10:20
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
if you can find him
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 05-21-08, 10:41
Gagnon Gagnon is offline
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).
Reply With Quote
  #6 (permalink)  
Old 05-21-08, 11:25
Gagnon Gagnon is offline
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?
Reply With Quote
  #7 (permalink)  
Old 05-21-08, 11:33
r937 r937 is offline
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #8 (permalink)  
Old 05-21-08, 11:33
r937 r937 is offline
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 05-21-08, 11:37
Gagnon Gagnon is offline
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
Reply With Quote
  #10 (permalink)  
Old 05-21-08, 11:38
Gagnon Gagnon is offline
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.
Reply With Quote
  #11 (permalink)  
Old 05-21-08, 11:47
blindman blindman is offline
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"
Reply With Quote
  #12 (permalink)  
Old 05-21-08, 11:48
gvee gvee is offline
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?
__________________
George
Twitter | Blog
Reply With Quote
  #13 (permalink)  
Old 05-21-08, 11:59
r937 r937 is offline
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #14 (permalink)  
Old 05-21-08, 12:02
r937 r937 is offline
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]

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #15 (permalink)  
Old 05-21-08, 12:06
Gagnon Gagnon is offline
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On