How to map to tables in database PHPMyAdmin
Posted
by
thegrede
on Stack Overflow
See other posts from Stack Overflow
or by thegrede
Published on 2012-06-18T15:05:47Z
Indexed on
2012/06/18
15:16 UTC
Read the original article
Hit count: 276
I'm working now on a project which a user can save their own coupon codes on the websites, so I want to know what is the best to do that,
Lets say, I have 1 table with the users, like this,
userId | firstName | lastName | codeId
and then I have a table of the coupon codes, like this,
codeId | codeNumber
So what I can do is to connect the codeId
to userId
so when someone saves the coupons goes the codeId
from the coupon table into the codeId
of the users table,
But now what if when a user have multiple coupons what do I do it should be connected to the user?
I have 2 options what to do,
Option 1,
- Saving the
codeId
from coupons table into thecodeId
of users table like1,2,3,4,5
,
Option 2
- To make a new row into the coupons table and to connect the user to the code with adding another field in the coupon table
userId
and putting into it the user which has added the coupon his userId of the users table,
So what of the two options is better to do?
Thanks you guys.
© Stack Overflow or respective owner