Foreign key relationship problem in PhpMyAdmin-Wamp

I'm having '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, things that with XAMP work automatically.

I need the relationship between the tables to be created automatically, even so that I be able to use Mysql with Hibernete (it happens with Hibernete too).

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

Thank you right now.

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

Category Table: insert the description of the image here

Table Called: insert the description of the image here

Insert into Table called through PHPMyAdmin:

insert the description of the image here

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

Author: Agnaldo Junior, 2017-08-11

1 answers

A foreign key (FK) is a column or combination of columns used to establish and enforce a link between the data of 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 containing the primary key value for one table are referenced by the column or columns of another table. This column becomes a foreign key in the second table.

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

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

Heads:

Select ca.nome, ch.titulo from categoria as ca, chamado as ch where ch.id_categoria = ca.id_categoria
 1
Author: Renato Junior, 2017-08-16 01:06:24