D
D
dmitriu2562018-12-26 16:21:47
MySQL
dmitriu256, 2018-12-26 16:21:47

Duplicate records, secondary key constraint How to get rid of?

Please help.
There are two tables
1) Products (only two fields for clarity) - main table (id - primary key, brand_id - secondary)
2) Brands table - secondary table (id - primary key, brand - plain text)
From table Products (brand_id) I refer to the id from the Brands table The
secondary key is superimposed on the brand_id field refers to the id field in the Brands table
The essence is to make a restriction on the number of brands
- in the Products table, you cannot add a brand with id = 6, since such an id does not exist in the Brands table.
When adding a new product in the Products table (via phpMyAdmin), there is an incomprehensible duplication of existing fields, namely
- duplicate lines are displayed (1 - zara, 2 - h&m empty line and the same but in reverse order)
In this field, I suppose to select only id without the brand name, but in fact all fields from the Brands table are pulled up.
What am I doing wrong?
I plan to design a database for an online store (product categories, subcategories, etc.)
I am attaching screenshots. I will be grateful for your help!
The fields id, brand_id have the same type, the same length, everything is identical.
Products
5c237f9093cbc399964592.png
table Brands
5c237f97024ca463314230.png
table Linking brand_id and id tables from the Brands table
5c237f9b903f7151598338.png
When adding a new product in the Products table, I get the following result, there should be no duplication and only a number.
5c237fa056351153487975.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Softer, 2018-12-26
@dmitriu256

This PMA "helps".
These are not duplicates. The first option (up to an empty line) is sorting by value, the second - by ID. I really don't know why they did that... :)

D
dmitriu256, 2018-12-26
@dmitriu256

I rummaged through the setting of secondary keys, sorted out the fields for matching data types, rummaged through the phpMyAdmin settings, everything turns out to be very simple.
The question is closed. If anyone encounters a similar problem - the fault of the settings of PhpMyAdmin itself
In my case,
When inserting data into the Products table, you need to click on the gear (Settings related to the page) - item "Sort foreign keys" - play around with the parameters
Previously, there were two lines
id-content
content- id
Now
id
id-content
Just a couple of id id values ​​- the result is empty, it is necessary to insert content
The screenshot is attached
5c23e67a232ef099250572.png5c23e6810cf65927538038.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question