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

iannarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SujithData ArchitectCommented:
>> '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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dqmqCommented:
First, PRICEPLAN.PlanCode needs to be a primary key or unique key.  I suspect it is the Primary Key, right?

Second, the foreign key constraint goes on the CONTRACT table and references the Primary Key of PRICEPLAN.



0
iannarAuthor Commented:
Thanks for  the help guys..I created another table for plancodes and had foreign key constraints from the other tables...works great!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.