Mysql – Referral table structure

database-designMySQLschema

I need to make a simple referral system and I have a database table set out as follows:

mem_id | date | refer_email | accepted 

And the meaning of such columns is the following:

  • mem_id: The member unique identifier who is making the referral.
  • date: The timestamp value of the request.
  • refer_email: The contact email address owned by the person being referred.
  • accepted: A CHAR value of Y or N that indicates if the referred person received acceptance.

I am not sure if this is best structure for this kind of scenario. I will be required to tally the number_of_users referred by each person mainly, and I expect a few more simple queries on the horizon.

Best Answer

I would add the following to that schema:

refer_mem_id - The member unique identifier of the person who has accepted the referral.

Remove the accepted column, the value in refer_mem_id gives you this information.