File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Foriegn key mapping

 
sammeta Phanikumar
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me any one.

PHani
 
Larry Frissell
Ranch Hand
Posts: 82
2
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic