I don't know about automatically, but you can use foreign keys to help.

create table student (
  student_id integer primary key,
  blah
);
create table workpiecelist (
  workpiecelist_id integer primary key,
  blah
);

create table uniqueworkpc (
  student_id int references student,
  workpiecelist_id int references workpieceList,
  blah,
  primary key (student_id, workpiecelist_id)
);



-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of csanyipal
Sent: Friday, October 20, 2017 3:57 PM
To: sqlite-users@mailinglists.sqlite.org
Subject: [sqlite] How to create primary key from two another PK's?

Hi,

I have a small and simple database MyStudents.db .
It has three tables: *student*, *workpiecelist*, *uniqueworkpc*.
How can I manage to get primary key (pk) automatically for *uniqueworkpc*
table which is composed by pk of *student* table and pk of *workpiecelist*
table like below?
03256789415632-2
where
03256789415632
is a pk of a student in *student* table, and
2
is an id of a workpiece in *workpiecelist* table.



-----
Best, Pál
--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to