icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » vBulletin question

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old February 25th, 2006, 8:49 PM   #1 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
Joined in Feb 2005
Lives in Vegas & New York
830 posts
Gave thanks: 2
Thanked 7 times
vBulletin question

If anyone uses vBulliten, maybe you can answer me this question. Maybe even Kayla can answer the question for me since surmunity uses it.

Anyhow, my question is:

How does vBulletin store birthdates in the database? 3 seperate columns for month, day, and year?

I'm considering changing my db schema to follow this kind of concept, which from my observation I believe is what vBulletin is currently doing. I have a query which finds the birthdays for a particular day, but it doesn't seem efficient since it can't use an index on the birthdate column.
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 25th, 2006, 11:36 PM   #2 (permalink)
?™
Resident.
 
David's Avatar
 
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7, Pass 78
14,157 posts
Gave thanks: 68
Thanked 53 times
Send a message via Skype™ to David
`birthday` varchar(10) collate latin1_general_ci NOT NULL default '',
__________________
I'm a web designer that founded the company Asheboro Creative. You can follow me on Twitter, add me on Myspace, or read my articles on Asheboro Tech.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 25th, 2006, 11:46 PM   #3 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,230 posts
Gave thanks: 49
Thanked 136 times
What's a value from that look like?
H is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2006, 12:38 AM   #4 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
Joined in Feb 2005
Lives in Vegas & New York
830 posts
Gave thanks: 2
Thanked 7 times
Ohhhhhh. Interesting.
I guess they store it as a string in some form of 'mm/dd[/yyyy]', where / could be any divider.

That makes sense. You can index the column, and then do a seaching using LIKE and use the column.
ex. LIKE 'mm%' for all the birthdays in a month, LIKE 'mm/dd%' for all the birthdays on a particular date.

That's useful. Perhaps I'll do 2 columns, 1 for birthday, and 1 for year.

Thanks David =D
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2006, 2:00 AM   #5 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,230 posts
Gave thanks: 49
Thanked 136 times
I fail to see why they wouldn't store it as a date field. You can still apply the LIKE operator/clause.

1986-10-03

LIKE '%-10-03'

You could explode the value in PHP to get the year and do the math to determine the age.
H is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2006, 2:24 AM   #6 (permalink)
?™
Resident.
 
David's Avatar
 
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7, Pass 78
14,157 posts
Gave thanks: 68
Thanked 53 times
Send a message via Skype™ to David
I expected it as a date field as well. Figured it would be easier that way. And the value from that would be just like 0000-00-00.
__________________
I'm a web designer that founded the company Asheboro Creative. You can follow me on Twitter, add me on Myspace, or read my articles on Asheboro Tech.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2006, 2:36 AM   #7 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
Joined in Feb 2005
Lives in Vegas & New York
830 posts
Gave thanks: 2
Thanked 7 times
Quote:
Originally Posted by Haugland
I fail to see why they wouldn't store it as a date field. You can still apply the LIKE operator/clause.

1986-10-03

LIKE '%-10-03'

You could explode the value in PHP to get the year and do the math to determine the age.
It affects index usage, and the optionality.

As far as optionality goes, vb lets you choose to include your birth year or not. With a date column, that wouldn't be possible, you'd have to put a year in.

As far as index usage, you couldn't use an index on the birthday column for birthday searches. The query you supplied, you'd have to scan the entire table for those birthdays. While that may not seem bad with small amount of users, when your user base grows, the time it takes to perform that query grows exponentially.

While it would probably take a fraction of a second with say 1000 members, with 100,000, it would take a couple of seconds. By storing the date with the year last in a varchar, the index can be used, and even with 100,000 members, the query can still take only a franction of a second.
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2006, 2:41 AM   #8 (permalink)
?™
Resident.
 
David's Avatar
 
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7, Pass 78
14,157 posts
Gave thanks: 68
Thanked 53 times
Send a message via Skype™ to David
You need to write a book.
__________________
I'm a web designer that founded the company Asheboro Creative. You can follow me on Twitter, add me on Myspace, or read my articles on Asheboro Tech.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2006, 2:52 AM   #9 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
Joined in Feb 2005
Lives in Vegas & New York
830 posts
Gave thanks: 2
Thanked 7 times
Quote:
Originally Posted by David
You need to write a book.
lol I'm too busy wondering what books I need to read to be writing my own.

I download a lot of pdfs and manuals relating to a lot of this stuff. I'm going to go to the book store and buy some more books soon. And I have my online bookmarks. Like http://www.oreillynet.com/linux/cmd/ , very good link. It's a list of linux commands from the Linux in a Nutshell book, which each command having a page with basic how to use info.
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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