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 > Confused about a larger db then im use to working with...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-02-09, 13:18
Krrose27 Krrose27 is offline
Registered User
 
Join Date: Mar 2009
Posts: 2
Confused about a larger db then im use to working with...

I haven't designed or worked with big DB's.

The site I am working on tracks Friend codes for a game i play...

I have one table called codes that looks like this:

Codes > id - int - auto inc - primary key
> code - varchar
> type - int (For identify owners or certian codes)
> lseen - datetime
> created - datetime
> banned - int

Users > id - int - auto inc - primary key
> username - varchar
> password - varchar
> created - datetime
> ip - int


The thing that I am planning to do is track what codes my users have used.

How should I go about doing this?

Mysql....
Reply With Quote
  #2 (permalink)  
Old 03-02-09, 14:48
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
How should I go about doing this?
Not sure how the type field is used in codes. Can a user use a code more than once and, if so, would you want to store each use? Anyway I'll take a wild stab at things by adding the table UserCodes :

Code:
create table UserCodes(
  user_id
  code_id
  date_used
)
Reply With Quote
  #3 (permalink)  
Old 03-02-09, 14:53
Krrose27 Krrose27 is offline
Registered User
 
Join Date: Mar 2009
Posts: 2
THey con only use the code once...

So when i pull it out through php I only want the codes they havent used.....

The table u mentioned is a one i thought of but I was having problems about figuring out how i would echo out all the codes ....

Me thinking... "Select * FROM codes WHERE code != UserCodes.code" <<<< this is where I am running into and idea problem.....
Reply With Quote
  #4 (permalink)  
Old 03-02-09, 15:25
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Originally Posted by Krrose27
So when i pull it out through php I only want the codes they havent used.....
Code:
Select code
FROM   Codes 
WHERE  not exists(
            select 1 
            from   UserCodes uc
            where  user_id = YourUser 
                   and uc.code_id = Codes.id )
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