Exercise: Creating the PhoneNumber Class
Now let's further enhance the application to include phone numbers for each contact. We will allow each contact to contain several phone numbers. As an exercise, create the application's PhoneNumber class. The class should be similar to Contact in that it meets the following requirements:
-
It belongs to the ContactDB package.
-
Its ClassType is Persistent (like Contact and unlike Address).
-
In addition to extending %PersistentOpens in a new tab, PhoneNumber extends %PopulateOpens in a new tab, %XML.AdaptorOpens in a new tab, and %ZEN.DataModel.AdaptorOpens in a new tab.
PhoneNumber should contain the following two properties:
Property Name | Type | Parameters |
---|---|---|
Type | %String | VALUELIST=,Business,Home,Mobile,Fax |
Number | %String | — |
After creating the class definition, click Build–>Compile to compile the class.
From the relational perspective, PhoneNumber like Contact has its own table. This is because it extends %PersistentOpens in a new tab. By contrast, Address does not have its own table. Its instances are stored in extra columns of the Contact table. This is because Address extends %SerialObjectOpens in a new tab rather than %PersistentOpens in a new tab.