lundi 20 avril 2015

SQLite : Choose the right record to link when auto increment primary key

I have an SQLite database, with a table having an auto increment integer as a primary key, and another table that is linked to this first table, through a foreign key. I don't understand how I can choose which row from the first table is to link with the right row from the second table.

Let me illustrate with an example :

Table student with auto increment primary key (0, 1, 2, ..., 10)

Table courses with these rows : name = 'French', grade = 'B', student (foreign key) = 3

How can I tell the database that the student 3 got B in French? Because I don't know which primary key (auto number) as been assigned to a student, I just know his name.

Aucun commentaire:

Enregistrer un commentaire