Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 11th, 2012  |  syntax: None  |  size: 0.40 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Organizing database tables - large number of properties
  2. CREATE TABLE Users (
  3.   user_id SERIAL PRIMARY KEY,
  4.   user_proerties TEXT
  5. );
  6.        
  7. CREATE TABLE UserBirthdate (
  8.   user_id BIGINT UNSIGNED PRIMARY KEY,
  9.   birthdate DATE NOT NULL,
  10.   FOREIGN KEY (user_id) REFERENCES Users(user_id),
  11.   KEY (birthdate)
  12. );
  13.  
  14. SELECT u.* FROM Users AS u INNER JOIN UserBirthdate b USING (user_id)
  15. WHERE b.birthdate = '2001-01-01';