0

I'm working on a data model for SIP routing information. Let's take as example the telephone number 1-212-123456. Two service providers A and B has the routing information (for example, IP addresses) to establish a SIP session to this telephone number.

Thus, in my model, I have an entity called TelephoneNumber. My question is: does it make sense to define the TelephoneNumber element as a value object?

First, a telephone number exists only in the context of one or more service providers. If no service provider knows the routing information for this telephone number, there is no reason for the latter to exist.

Second, if TelephoneNumber is a value object, there will be two instances of the same telephone number, one for each service provider. In this case, the primary key of the entity would include a foreign key referencing ServiceProvider. In this case, I see there is some data duplication.

Thanks

0

1 Answer 1

2

A value object has no identity, it is identifiable by its attributes. If two instances of your "TelehponeNumber" class are defined as equal if the contain the same number they can be treated as value objects, but you to be very formal about your approach with value objects. If you define "TelephoneNumber" as a value object, you don't stuff it into its own table and give it an identity (No primary/foreign key mumbo jumbo), you put it in as a member of another entity, (the routing information seems to be the right place if I understand your domain correctly). You really don't care about how many instances there are of value objects as they are simply a part of another entity.

Typical value objects are phone numbers, e-mail addresses, money, social security number, etc

Sign up to request clarification or add additional context in comments.

2 Comments

Finally, I defined the TelephoneNumber type as an entity since I need to distinguish between telephone numbers of a single service provider. The telephone number string would be the identity of the TelephoneNumber entity and this identity would be local to ServiceProvider.
The question of equality is really the key point though. If you have two telephone numbers, one of (111) 111-1111 for Verizon and one of (111) 111-1111 for AT&T, do you consider them equal?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.