How do I make two references from one table into two tables?

0

Well, I have 3 tables

  • tbl_users
  • tbl_article
  • tbl_profile
  • I need tbl_usuarios to be related to tbl_artigos and tbl_profiles.  How could it be done?

    Tbl_users table:

    +-----------------+--------------+------+-----+---------+----------------+
    | Field           | Type         | Null | Key | Default | Extra          |
    +-----------------+--------------+------+-----+---------+----------------+
    | usuario_id      | int(11)      | NO   | PRI | NULL    | auto_increment |
    | usuario_usuario | varchar(30)  | NO   |     | NULL    |                |
    | usuario_email   | text         | NO   |     | NULL    |                |
    | usuario_senha   | text         | NO   |     | NULL    |                |
    | usuario_imagem  | varchar(100) | YES  |     | NULL    |                |
    | usuario_status  | int(1)       | NO   |     | NULL    |                |
    | id_perfil       | int(11)      | YES  | MUL | NULL    |                |
    +-----------------+--------------+------+-----+---------+----------------+
    

    Table tbl_artigo

    +---------------+--------------+------+-----+-------------------+----------------+
    | Field         | Type         | Null | Key | Default           | Extra          |
    +---------------+--------------+------+-----+-------------------+----------------+
    | artigo_id     | int(11)      | NO   | PRI | NULL              | auto_increment |
    | artigo_titulo | varchar(100) | NO   |     | NULL              |                |
    | artigo_imagem | varchar(80)  | YES  |     | NULL              |                |
    | artigo_autor  | varchar(45)  | NO   |     | NULL              |                |
    | artigo_post   | text         | NO   |     | NULL              |                |
    | artigo_data   | timestamp    | YES  |     | CURRENT_TIMESTAMP |                |
    | artigo_status | int(1)       | NO   |     | NULL              |                |
    | id_artigo     | int(11)      | YES  |     | NULL              |                |
    +---------------+--------------+------+-----+-------------------+----------------+
    

    Table tbl_profile:

    +------------------+--------------+------+-----+---------+----------------+
    | Field            | Type         | Null | Key | Default | Extra          |
    +------------------+--------------+------+-----+---------+----------------+
    | perfil_id        | int(11)      | NO   | PRI | NULL    | auto_increment |
    | perfil_cargo     | varchar(100) | YES  |     | NULL    |                |
    | perfil_telefone  | int(30)      | YES  |     | NULL    |                |
    | perfil_descricao | text         | YES  |     | NULL    |                |
    | id_perfil        | int(11)      | YES  |     | NULL    |                |
    +------------------+--------------+------+-----+---------+----------------+
    

    This will be used so that when the user writes his article I will take the image of the user that is in the tbl_usuario and other information that are in another table

    I need to know how I do this.

        
    asked by anonymous 14.10.2016 / 23:37

    0 answers