1
I am learning MYSQL on my own due to the teaching restriction that there is in my city and its vicinity, so I would like information on how to use CASCADE in the table that I have with this structure:
tblUsuario idu int not null auto_increment pk name
tblTelefoneN idt int not null auto_increment pk tipotel int not null //identifier to tell if it is cellular etc. numerotel varchar(15)
tblRelacaoUsuTel idu int not null idt int not null
My doubts are as follows::
The relation table as I understand it so far will get a unique information in two other tables, user and phone, so I have two Foreign Keys that refer to other correct Primary Keys?
When making the main record after reading in a forum that in a transaction we have N routines, I created one for each phone insert (4 phone fields, using Lazarus IDE [Delphi style]), then I have an INSERT INTO... for each phone and I am manually entering the data in table tblTelefoneN and tblRelacaoUsuTel, I use LAST_INSERT_ID() for this 'gambiarra'.
How to proceed with the update, I read about CASCADE and how it makes 'linked' changes, can I use CASCADE somehow in my case? (since the user id does not change) or should change only the field where you have the phone number in tblTelefoneN and the type of it?
I appreciate the answers and the understanding.
1 Correct 2 XX 3 I am not sure of your case but I believe that the CASCADE is not used to guarantee an integrity between the tables as the case , delete , not allow deletion or change to non-existent key , delete/change in "cascade"
– Motta