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 > Database Server Software > MySQL > Design Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-24-10, 15:04
Greelmo Greelmo is offline
Registered User
 
Join Date: Jul 2009
Posts: 4
Question Design Question

Hello all,

It's been quite some time since I've posted to these forums. I'm currently involved in a rather robust database project, and can't quite get my head around how to structure it.

Basically, I have a single table of users. Each day, each user will supply a single value. I want the database to be able to then track these values over any period of time among any subset of users. So, it can look at all users over the past year, or one user over the past week... that sort of thing.

I don't know how to store these daily values. Any ideas?
Reply With Quote
  #2 (permalink)  
Old 01-24-10, 15:20
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by Greelmo View Post
I don't know how to store these daily values. Any ideas?
Code:
CREATE TABLE dailyvalues
( userid INTEGER NOT NULL 
, FOREIGN KEY ( userid ) REFERENCES users ( id )
, thedate DATE NOT NULL
, thevalue INTEGER NOT NULL
, PRIMARY KEY ( userid,thedate )
);
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Tags
daily, database, design, mysql, store

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