|
|
Question : Implementing an Entiity Relation diagram
|
|
I am a student database designer. I'm trying to link these two tables below: CONTRACT and PRICEPLAN
I want the two tables to be linked together via the 'PlanCode' field.
The CONTRACT table details customer data and specifies what "plancode" they have.
The PRICEPLAN table details cost information for telephone services
When I try to implement the PRICEPLAN table in Oracle and put 'plancode' as a foreign key for CONTRACT, it says 'no matching unique or primary key for this column-list'
Any suggestions on how I can implement this?
CONTRACT Account# Phone# ContractDate PlanCode 12345 746-5487 2/2/1990 ABC 12346 548-5486 25/2/91 ABC 12347 246-8754 1/4/1988 BCD 12348 587-5487 14/3/89 BCD 12349 364-2154 21/4/94 ABC
PRICEPLAN PlanCode ServiceType Cost ABC VoiceCallPk 5 ABC DataCallPk 4 ABC MMCallPk 7 ABC TextMsgPk 2 ABC MMMsgPk 3 ABC VoiceCall 4 ABC DataCall 3 ABC MMCall 6 ABC TextMsg 1 ABC MMMsg 2 BCD VoiceCallPk 6 BCD DataCallPk 5 BCD MMCallPk 8 BCD TextMsgPk 3 BCD MMMsgPk 4 BCD VoiceCall 5 BCD DataCall 4 BCD MMCall 7 BCD TextMsg 2 BCD MMMsg 3
|
Answer : Implementing an Entiity Relation diagram
|
|
>> 'plancode' as a foreign key for CONTRACT Foreign keys require the master table column to be UNIQUE/ a primary key column. Here plancode in CONTRACT is none of them. You cannot implement this constraint here.
Alternative is: You can have another table for placodes. ANd have a foreign key constraint to that table from CONTRACT and PRICEPLAN.
|
|
|
|