Hi to all:

In the schema of day 3 of Jobeet Book:

  jobeet_job:
    id:           ~
    category_id:  { type: integer, foreignTable: jobeet_category,
foreignReference: id, required: true }

category_id ..... required: true

It means, that when we create a new job, we most set a Category....

What happens when we delete a category ??

I take the liberty to change:
#/data/fixtures/010_categories.yml
#---------------------------------------------------------
JobeetCategory:
  design:        { name: Design }
  programming:   { name: Programming }
  manager:       { name: Manager }
  administrator: { name: Administrator }

JobeetAffiliate:
  testaffiliate: { url: test }

JobeetCategoryAffiliate:
  relation1:
    category_id:  programming
    affiliate_id:  testaffiliate
#---------------------------------------------------------

If you test directly on phpmyadmin, delete a category with id = 2  (
programming  )..

*SQL query:*

DELETE FROM `jobeet_category` WHERE `jobeet_category`.`id` =2 LIMIT 1

*MySQL said: *
 #1451 - Cannot delete or update a parent row: a foreign key constraint
fails (`jobeet/jobeet_job`, CONSTRAINT `jobeet_job_FK_1` FOREIGN KEY
(`category_id`) REFERENCES `jobeet_category` (`id`))


If you ask a opinion, i think that the follow is better:

category_id:  { type: integer, foreignTable: jobeet_category,
foreignReference: id, required: true, onDelete: cascade }

If my relationship demands a field (required: true), and we don't hardcoding

what happen when a job was delete, then we can say that always is better
also set : onDelete: cascade
I wait for yours comments

-- 
Cr. Puentes Diaz
MP 10.12726.9
Córdoba - Argentina

www.puentesdiaz.com.ar/blog/
www.puentesdiaz.com.ar/blog/novedades
www.puentesdiaz.com.ar/blog/curriculum-vitae
Linux User n° 441474
Ubuntu/Symfony/Eclipse Rocks!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to