Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 The Yak Corral
 Migration Fun

Author  Topic 

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-22 : 16:27:03
Writing code and doing some training to see if we can write a migration sproc between an old version of a database to a new empty database version

We3 decide the new version of SQL server should electrocute a data modeler who makes their date columns NOT NULL and doesn't provide a default

What type of columns might these be that are defined as

col datetime NOT NULL

birthdate babies not born yet
DOD I'm not dead yet
Effective date would have to force them to guess
Term date would have to force them to guess
Maybe Tax Deadline Date..but that can be changed or unknown
ADD_TS ...well I give that a default
UPD_TS...row has been modified (although I cheat here and give it a default anyway)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-22 : 19:37:26
Wow, I hope you don't think I just feel like arguing with you today Brett, but I can easily think of an appropriate place for DATETIME NOT NULL with no default.

Say you have a calendaring application, or a hotel reservation system. Say an event table.
Create Table Events (
EventId int IDENTITY (1, 1) NOT NULL,
EventDate SMALLDATETIME NOT NULL,
UserId int NOT NULL,
Constraint FK_EVENT_USER Foreign Key (UserId) REFERENCES ([user].[id])
);


Here we have a datetime defined as not null with no default, and it's appropriate.

Of course all of the examples you listed, should have been defined as nullable. That's when you get to send it back to the developer and make 'em fix it
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-22 : 19:56:55
I'm ALWAYS up for a good discussion

For example..what value doe that table have

Some User had an Event

That's like my ADD_TS example of The ONLY Reason to have a datetime NOT NULL...I noticed you didn't make a default

Meaning, for the "Event" they most know what the event, why it happened and WHEN it happened, or is going to happen

UNTIL you really know...it meaningless

"OH, hi AVIS IO need to Rent a car"

"Surely sir, when do you want it?"

"I don't know, but can you still take a reservation?"

Try That



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-22 : 19:57:34
Never mind...you can't even get a phone number on the main page

http://www.avis.com/car-rental/avisHome/home.ac



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-22 : 21:02:03
lol.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-22 : 21:08:45
I agree with you. I'm just saying that there are events that are meaningless until the date of the event is known. like your rental car example.

so in that case we can have a reservation date not null without having to provide a default...right?

am i missing a critical point here? (wouldnt be the first time lol)
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-22 : 21:40:50
yes you are

And Avis knows it

Try and make a reservation without a date

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-22 : 22:32:39
That's my point exactly. So the reservation table can have the date as not null, and doesn't need to provide a default.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-11-23 : 01:06:59
I'm not looking forward to next year. When I test our checkout it is so easy ... spaces are all optional

Name = 1
Credit card number (OK ... I have to type a "4" here) - 4111 1111 1111 1111
Expiry date 11 11 11
Security number 111

But after the 11th November next year ...

I hate date defaults. Harks back to putting 99/99/99 in dates as a marker-date. Just leave them NULL if the value is unknown, otherwise operators will put bogus values in to get past them. I known one would.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-23 : 09:19:00
you mean 9999-12-31

Or in DB2

0000-01-01

If you have to code for something to know there is no date, just code for nulls



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -