Foreign key relationship problem in PhpMyAdmin - Wamp

2

I have 'problem' in my Wamp, more precisely in the latest version (Wampserver 3.0.6 64 bit x64).

When I create 2 tables, example:

CREATE TABLE categoria(
    id_categoria INT NOT NULL AUTO_INCREMENT,
    nome VARCHAR(100) NOT NULL,
    PRIMARY KEY(id_categoria)
);


CREATE TABLE chamado(
    id_chamado INT NOT NULL AUTO_INCREMENT,
    id_categoria INT NOT NULL,
    titulo VARCHAR(45) NOT NULL,
    PRIMARY KEY(id_chamado),
    FOREIGN KEY(id_categoria) REFERENCES categoria(id_categoria)
);

I run and create the tables, however, PhpMyAdmin does not automatically create the relationship between the foreign key and the primary key of the other table, which works with XAMP automatically.

I need to automatically create the relationship between the tables, so that I can use Mysql with Hibernete (it happens with Hibernete too).

I think it might be some configuration, would anyone know how to solve it?

Thank you in advance.

----------- > Update:

Table Category:

CalledTable:

InsertintableCalledthroughPHPMyAdmin:

As long as the category table has records, I can add any id in the foreign key of the called table that no error occurs. Things that, using Xamp, works, which lists the two tables and opens an option with the id of the foreign key at the time of the insert.

    
asked by anonymous 11.08.2017 / 13:19

1 answer

1
  A foreign key (FK) is a column or combination of columns used to establish and enforce a link between the data in two tables in order to control the data that can be stored in the foreign key table. In a foreign key reference, a link is created between two tables when the column or columns that contain the primary key value for a table are referenced by the column or columns of another table. This column becomes a foreign key in the second table.

So it can be null, or have a value not referenced in the other table. It does not necessarily have to exist in both tables.

From the photos the foreign key is working. Make a query that uses data from both tables to test its functionality.

Test:

Select ca.nome, ch.titulo from categoria as ca, chamado as ch where ch.id_categoria = ca.id_categoria
    
16.08.2017 / 03:06