Yeah, use two FKs, then you can obtain this "combined" value on select:
select printf("%s-%s", student_id, workpiecelist_id) as id from uniqueworkpc
On Fri, Oct 20, 2017 at 11:05 PM David Raymond <[email protected]>
wrote:
> 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:[email protected]]
> On Behalf Of csanyipal
> Sent: Friday, October 20, 2017 3:57 PM
> To: [email protected]
> 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
> [email protected]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users