Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

True or false: an object instance occupies 1 row in its corresponding RDBMS table

 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume a Car object. A Car has 4 doors and one engine. A Car can carry one or more Persons, and one or more LaptopComputers.

The code might be:




Let's assume we want to search on all Cars having a laptopComputer of a certain COMPUTER_TYPE, or Person with a certain lastName.

Wouldn't the RDBMS mapping for class Car consist of 3 tables? I would assume 3 tables. Yes, even an RDBMS table for the Vector laptopComputers, which contains nothing more than simple Strings. Thus:

CAR_TABLE, PERSON_TABLE, LAPTOPCOMPUTER_TABLE.

with CAR_TABLE standing in one-to-many relation with both PERSON_TABLE and LAPTOPCOMPUTER_TABLE

I would assume that for every Vector (or any other List, Collection, Array, etc.) you would map a separate table in the RDBMS.


I.e. I assume that an instance of a Car object would never occupy more than 1 row in the RDBMS CAR_TABLE.

is this right?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would be a sensible assumption. How this would be implemented would depend on which Object-Relational Mapping technology you used, and how you decided to map it, but typically something that is a definable type (such as your Car class) would correspond to one row in one table.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!