Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Foreign Keys Integrity - Please explain? 27 Mar 2012 04:12 #1733

  • edwardcox
  • edwardcox's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Here to help.
  • Posts: 131
  • Thank you received: 26
Hello All,

Could someone please explain to me what the settings in the Foreign Key Integrity are:
  • none
  • reset
  • cascade

That might help me better understand what I am doing when using a FK.

Kind Regards,

Edward
Passionate Joomla! Developer and J-Cook pro evangelist.
www.jcombuilder.com - we build great Joomla!® Components so you don't have to.

Please Log in or Create an account to join the conversation.

Re: Foreign Keys Integrity - Please explain? 28 Mar 2012 04:41 #1750

Hi Edward,

I think the explanation under the question mark in the builder is already clear:
None : Keep object with his broken key.
Reset : set to 0.
Cascade : delete all objects from this table that refers to it.

An example with two tables:
TableA
TableB: Foreign key TableA_id.

If you delete in TableA a record with TableA_id value 1 the process is:
None:
Records in TableB keeps there reference to TableA_id 1. A result could be that views will not work or at least misses data from TableA because the record does not exist anymore.

Reset:
Records in TableB with TableA_id value 1 will be reset to 0. Same result as above but it is easier to capture the 'wrong' records.

Cascade:
Records in TableB with TableA_id value 1 will be deleted. Dangerous because all records with the TableA_id reference will be deleted in TableB. Important to build in a warning or an extra confirmation of the user.

Hope this will help you.

Best Regards,
Adriaan
Molenwal1 Webdesign
www.molenwal1.nl
The following user(s) said Thank You: admin, griiettner, VeCrea, edwardcox

Please Log in or Create an account to join the conversation.

Re: Foreign Keys Integrity - Please explain? 28 Mar 2012 04:47 #1751

  • edwardcox
  • edwardcox's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Here to help.
  • Posts: 131
  • Thank you received: 26
Big Thanks Adriaan,

Damn that elusive Question Mark help symbol I keep forgetting about.
Your explanation is clear and concise. Much appreciated.

Regards,

Edward
Passionate Joomla! Developer and J-Cook pro evangelist.
www.jcombuilder.com - we build great Joomla!® Components so you don't have to.

Please Log in or Create an account to join the conversation.

Re: Foreign Keys Integrity - Please explain? 30 Mar 2012 07:46 #1789

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
And for the moment, Cook don't ask you anything before to process. It is only an automatism when you are sure of what you do. If not, don't allow final user to delete.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.064 seconds

Hi All just wanted to add one more "thank you" voice to all those who discovered the value of this amazing application. The website I was working on went to production few days ago and I do not want to even try to imagine what would it take to build it without j-cook. So - endless thanks keep it running and evolving I believe it deserves to be the core tool for any joomla application! Thanks!
Michael (bmk028 - Forum)  

Get Started