• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Database in table problem

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scenario:
i have a table name children, fields are (PK,IDnumber,nameOfChild) - idnumber there is a foreign key.
for example idnumber = 222, which has 3 children. named lets say a,b,c so this is the table look like
children
PK IDnumber nameOfChild
1 222 a
2 222 b
3 222 c

in java i make a class Children with fields pk,idnumber,name

when i fetch it to the database, it looks like this
List<Chidlren> children = <e.g. the database will return the Children classes of IDnumber = 222>
now we have 3 classes, the children size is 3;
the problem is, when i edit the children making the children of 222 to 2? (e.g. a & b only because c is mistakenly inputted).
(remember that it is now in the database the a,b,c)

> will i delete the idnumber = 222 in the database, table name children?(e.g a,b,c) and add back the 2? is this correct or is there any better idea in doing
this.
> how will i tell the table named children that i want to delete the child c? (not the sql on deleting) i mean the approach to tell the database.

 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question would sit better on our databases forum. Moving thread.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roldan,
If you have a cascade delete set, deleting the parent row will delete the children.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic