Structure of a database for 'Secret Friend'

5

I am creating a secret friend system for the family, where it will be possible to have:

  • User registration with your given data (ex: Tennis size, shirt, etc ...) ;
  • Registered user groups;
  • Generate a draw with users entered into that particular group;
  • Wish List;
  • A mural in the group to leave (Anonymous or not) ;
  • Notifications (if there is any message inserted in the group, requests for friendship, etc ...);
  • Relationship system (Friends) .

What has already been done:

 TB_USUARIO |   TB_PERFIL   |   TB_GRUPO    |   TB_RELACIONAMENTO       |   TB_MENSAGEM_GRUPO   |   TB_DESEJO               
------------|---------------|---------------|---------------------------|---------------------- |-----------------
ID_USUARIO  |   ID_PERFIL   |   ID_GRUPO    |   ID_RELACIONAMENTO       |   ID_MENSAGEM_GRUPO   |   ID_DESEJO
ID_PERFIL   |   NOME        |   ID_USUARIO  |   ID_USUARIO_SOLICITOU    |   ID_GRUPO            |   ID_USUARIO
USUARIO     |   SOBRENOME   |               |   (usuário que solicitou) |   ID_USUARIO          |   DESEJO
SENHA       |   EMAIL       |               |   ID_USUARIO_RECEBEU      |   MENSAGEM            |
                                            |   (usuário que recebeu)   |   DATA_HORA           |

My biggest question is about Grupo de Usuários , Notificações and Gerar um sorteio com os usuários inseridos em um determinado grupo . What is the best way to structure the database, and what logic (in php) can I use to make the draw?

    
asked by anonymous 03.11.2014 / 12:32

1 answer

3

There are several ways and ways, it depends on who is modeling the system.

Let's suppose the group table:

TB_GRUPO

  • ID_GRUPO (identifier);
  • NOME_GRUPO (name, hidden friend company xyz);
  • DATA_SORTEIO (which will be automated by the system);
  • DATA_ENTREGA (would be the date of the exchange of gifts);
  • LOCAL_ENTREGA (would be the location of the exchange of gifts);
  • VALOR_MIN (would be the minimum value of the present, if it does not have min it stays as null for example)
  • VALOR_MAX (would be the maximum value of the present, same idea of the minimum)
  • (if the admin wanted it before, by pushing a button for example, and that 'flag' would indicate that it has already been drawn)

A group could have one or more administrators

STATUS

  • TB_ADMS_GRUPO (auto incrementable, just to index)
  • ID
  • ID_GRUPO

One group could have multiple participants

ID_USUARIO

  • TB_MEMBROS_GRUPO (auto incrementable, just to index)
  • ID
  • ID_GRUPO
  • ID_USUARIO (would start as ID_AMIGO , when the draw would occur would be filled with null of the friend raffled)

At the time of the draw, you would select all members and fill in everyone's friend column. Be careful in the draw algorithm. The ideal is to be cyclical, or the first to give the present always be the last to not break the delivery wheel. Do not draw your own person for yourself (basic).

For notification, simply send an email to the user's email at the time of the action that should be notified. You do not necessarily need a registration for the notification.

You can even register the notification, but in my opinion it is unnecessary, after all if you notify a user that he has received a new message, the message will be recorded. If it receives an email informing this notification, it is enough for it to go in the system and verify the message that is REGISTERED. Already the notification, if registered, what would it serve?

See examples, browse through secret friend sites and see how they work, this will help you. A very good one to make the joke is the link .

    
03.11.2014 / 13:30