-1

A very quick question. I have a student table with columns: student_email(PK), student_name, student_surname, password, course

and another table called 'feelings' where the student can log how they're feeling every day. Columns: feeling_id(PK), feeling_title, feeling_text

I'm just wondering how I would be able to link these two tables together in order for students to log their own feelings and then also for the student to view all the logs they have saved.

Thank you/

  • 2
    Add student_id to feelings table. – jarlh Aug 24 '16 at 13:09
  • I would add student_email(FK) to the table 'feelings' that reference student_email(PK) in the table 'student' :) Then afterwards you can join these tables on this column and see what 'feelings' are connected to each 'student' – Moptan Aug 24 '16 at 13:09
  • @jarlh Strangely though OP doesn't have any student id. The email is the id in this case. – CodyMR Aug 24 '16 at 13:36
  • 1
    @Cody360c, I know... (I'd switch to an id column as pk, and a unique constraint for the email column. And then add a fk.) – jarlh Aug 24 '16 at 13:41
  • @jarlh As would I. I thought you might have missed it or maybe assumed it existed since you didn't have an explanation afterwards : ). – CodyMR Aug 24 '16 at 13:43

1 Answers1

1

Add a column student_email in 'feelings' table as foreign key which will refer the student_email(PK) column of Student table.

Sundararaj Govindasamy
  • 8,180
  • 5
  • 44
  • 77