1
What you lack is to set the Id column in your Team table as the primary key.
To add a primary key to a table, you can use the command ALTER TABLE
.
Your syntax
is:
ALTER TABLE table_name
ADD CONSTRAINT constraint_name PRIMARY KEY (column1, column2, ... column_n);
Or by SQL Developer, right-click on the desired table and seal the menu Edit.
And finally click OK.
References:
Oracle / PLSQL: Primary Keys. Available in: https://www.techonthenet.com/oracle/primary_keys.php. Accessed: 25 Nov. 2017.
Getting Started with Oracle SQL Developer. Available in: http://www.oracle.com/ocom/groups/public/@otn/Documents/webcontent/257055.htm. Accessed: 25 Nov. 2017.
Daina, from what I read in the documentation, it seems to me that your Team table has no primary key defined. What seems strange to me, that Pleo print of your ER model, your Team table, does not have a Team_id column but a Id column.
– Pablo Tondolo de Vargas
Pablo thanks was really this, but I was not managing to define team_id as FK of the table Attendance and Person, was giving the error that I show in the photo, but I managed to define team_id in the table LEAGUE as Primary and Foreign will be by in the table LEAGUE was already as Primary?
– Diana Madeira
Very likely yes, at the time q vc defined q the link between the League table and Team, and the primary key is in the League table, vc created a 1 to N ratio between League and Team, but at the time q vc set the PK in Team, you will have a 1-to-1 ratio between League and Team tables. All you have to do is take care of which one of you has the primary key when it comes to defining FK. For example if you set q a Referencing Column, is the Team table Id, it means that the record will have to exist first in the Team table, and then you enter it into the League table. If I’m wrong, correct me.
– Pablo Tondolo de Vargas