• 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

Foriegn key mapping

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have two tables as below.

Table Employee(
Employee_Id: Integer(11)
Employee_Name: Varchar(22)
)

Table Employee_Address(
Emp_Id: Integer(11) FK -> Employee
City: Varchar2(30)
Country:Varchar2(20)
)


All I want When ever a record is entered in Employee_Address, That record must have a mapping in Employee(Employee_Id) table.

I went through many articles on this.. many of them suggested that... in Employee .java should contain an object and setters/getters for Employee_Address. I dint understand this. Because if I do like this...I need to fill Employee_Address object to enter any record in Employee table.

I want Employee record to be entered with out any Employee_Address details. But to enter a record into Employee_Address must have a record in Employee.

Please clear me on this.

Thanks,
Phani
 
sammeta Phanikumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me any one.

PHani
 
Ranch Hand
Posts: 82
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe you want to use a one-to-one mapping relationship. See this link for an example with employee name and address.
 
sammeta Phanikumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Larry for your reply,

But in this example if I want to enter a record only in Employee table then i have to setAddress with an Address object. this i do not want.

I just want work with Employee independently. But a record in Address must a have reference in Employee table.

Please help me in this...

Phani
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic