Reputation: 3535
Lets say you have an object, User
that comes from a table called user
, and that object has a property called primaryAddress
. primaryAddress
is a foreign key to a reference table or list of addresses in an Address
table.
When building the User
object, you can associate properties of the address based on the foreign key/primary key relationship. For example, I can associate the properties streetAddress
, city
, state
, postalCode
, etc.. simply because I can join the data from User
to Address
.
In a relational database you get this data usually though a join like INNER JOIN
or OUTER JOIN
. However, I'm not sure what this type of relationship is called in object oriented programming (OOP) when an object "obtains" data from another object.
Upvotes: 2
Views: 172
Reputation: 10988
In OOP/OOD the closest thing you'd have is probably aggregation or composition - you wouldn't refer to the address by ID but rather have a non-owning reference (in case a particular address could be used by multiple people, e.g. families), or an owning reference (in case there's always a 1-1 relationship between a person and their particular address in the db).
Upvotes: 2