GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  OOPS

 Print  |  
Question:  I have just started doing OOP design. My experience has been in RDBMS. Where we work with tables, relation between them defined using foreign keys. Can anyone pl. help in designing classes for a simple case here. There are two tables (states, districts). Districts contains stateId as foreign key. So state to district 1-many relation is there. Such things how do we design in oops. Thanx in advance



October 10, 2005 00:54:36 #1
 sudha Microsoft Expert  Member Since: October 2005    Total Comments: 3 

RE: I have just started doing OOP design. My experienc...
 

Well. I found the answer myself. I am putting it here for the benefit of others.

State - districts is a 1-many relation (bi-directional relation).

here In Oops it becomes has a relations. So we have to design a state class which will contain a collection of ditricts as one of the attributes.

This is a bi-directional relation. So we have to design a distric class where a state class is denoted by means of an attribute.

State class will have getDistricts, setDistricts, addDistrict, deleteDistrict methods

District class will have getState, setState method

     

 

Back To Question