A
A
Alexey2017-10-19 13:03:29
MySQL
Alexey, 2017-10-19 13:03:29

Deleting one of the records from a MySQL table?

The task is to set prices for a period for a certain type of positions with / without a coefficient.
59e874bf64236564043182.png
Resolved:
Link two tables price and position by type (there are two in total, TINYINT (1) is taken as the basis). One-to-many relationship.
In the price table, as a primary key and a unique index, 3 fields are used - price type, price start date and a multiplier.
The position table also has a type field and an external link is established with the price table using the corresponding field.
After entering several values ​​for one type of positions in the price table for different periods, it is not possible to delete an incorrectly entered entry, since it is a foreign key for the positions table.
Are there any options for solving this problem other than breaking the connection?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-10-19
@skazi_premiere

Option 1: Change to ON DELETE CASCADE, in which case all related records will also be deleted.
Option 2: Change to ON DELETE SET NULL, in this case, in all related records, the link field will be NULL.
Option 3: Manually delete all related records first.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question