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.085 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started