title: Nested table primary and foreign key in Oracle
body: <p>I'm trying to add a primary and foreign key to a nested table, struggling to know how.</p>
  
  <p>This is what I have;</p>
  
  <pre><code>create or replace type profile as object 
  (
  id VARCHAR2(10), --- Suppose to be Primary Key
  userID VARCHAR2(10) --- Suppose to be Foreign Key for user table
  );
  
  create or replace type profile_nest as table of profile;
  
  CREATE OR REPLACE TYPE user_t UNDER group_T
  (profile profile_nest_ty,);
  
  
  CREATE TABLE user OF user_t
  (id NOT NULL,
  PRIMARY KEY (id), 
  nested table profile store as profile_storage_tbl;
  </code></pre>
  
  <p>Now the problem is this part, trying to do a foreign key -</p>
  
  <pre><code>alter table profile_storage_tbl add CONSTRAINT fk_userID FOREIGN KEY (userID)
  REFERENCES user(id);
  </code></pre>
  
  <p>Gives this error -</p>
  
  <blockquote>
    <p>*Error starting at line 3 in command:<br>
    alter table profile_storage_tbl add CONSTRAINT fk_userID FOREIGN KEY (userID)
    REFERENCES user(id)<br>
    Error report:<br>
    SQL Error: ORA-30730: referential constraint not allowed on nested table column
    30730. 00000 -  "referential constraint not allowed on nested table column"<br>
    *Cause:    An attempt was made to define a referential constraint on a nested
               table column.<br>
    <em>Action:   Do not specify referential constraints on nested table columns.</em></p>
  </blockquote>