Okay, sorry for the confusion. As you can see, carrier_code links to business (business_id). I'd like to create a map property on my Business domain object called getCarrierCodes(). I would expect this map to use the "number" field on the carrier_code table. The elements inside the map should be the CarrierCode domain object itself, not a seperate value. I hope that helps.
Code:
CREATE TABLE carrier_code (
id integer DEFAULT nextval('carrier_code_id_seq'::text) NOT NULL,
number character varying(4) NOT NULL,
business_id integer NOT NULL
);
ALTER TABLE carrier_code ADD CONSTRAINT carrier_code_pkey PRIMARY KEY(id);
ALTER TABLE carrier_code ADD FOREIGN KEY (business_id) REFERENCES business(id) ON UPDATE CASCADE;
CREATE SEQUENCE carrier_code_id_seq;
CREATE TABLE business (
id integer DEFAULT nextval('business_id_seq'::text) NOT NULL,
address character varying(100) NOT NULL,
postal_code character varying(15) NOT NULL,
province character varying(20) NOT NULL,
country_id integer NOT NULL,
phone_number character varying(14) NOT NULL,
fax_number character varying(14) NOT NULL,
account_state integer DEFAULT 0 NOT NULL,
name character varying(40) NOT NULL,
mailbox character varying(35) NOT NULL,
city character varying(50) NOT NULL,
"type" character varying(40) NOT NULL,
administrator_id integer NOT NULL,
billing_address character varying(100) NOT NULL,
billing_city character varying(50) NOT NULL,
billing_province character varying(20) NOT NULL,
billing_country_id integer NOT NULL,
billing_postal_code character varying(15) NOT NULL,
currency character(3) NOT NULL,
payment_plan_id integer NOT NULL,
use_email_invoicing boolean NOT NULL,
verification_date date,
approval_date date,
time_zone_id integer NOT NULL,
distributor character varying(200) NOT NULL,
CONSTRAINT business_account_state_check CHECK (((account_state >= 0) AND (account_state <= 3)))
);