title: PostgreSQL Foreign Key syntax
body: <p>I have 2 tables as you will see in my PosgreSQL code below. The first table students has 2 columns, one for <code>student_name</code> and the other <code>student_id</code> which is the Primary Key.</p>
  <p>In my second table called tests, this has 4 columns, one for  <code>subject_id</code>, one for the <code>subject_name</code>, then one for a student with the highest score in a subject which is <code>highestStudent_id</code>. am trying to make <code>highestStudent_id</code> refer to <code>student_id</code> in my students table. This is the code I have below, am not sure if the syntax is correct:</p>
  <pre><code>CREATE TABLE students ( student_id SERIAL PRIMARY KEY,
                   player_name TEXT);
  
  CREATE TABLE tests ( subject_id SERIAL,
                     subject_name,
                     highestStudent_id SERIAL REFERENCES students);
  </code></pre>
  <p>is the syntax <code>highestStudent_id SERIAL REFERENCES students</code> correct? because i have seen another one like <code>highestStudent_id  REFERENCES students(student_id))</code></p>
  <p>What would be the correct way of creating the foreign key in PostgreSQL please?</p>