I have a table where I have 2 pieces of information whose combination must always be unique.
By definition, if we look at these two columns for any given row, they are unique and should be primary
or at least a candidate
key, but in my case they are primary
.
However, when I try to create the table with Flask SQLAlchemy
I am told that I cannot create a table without a primary key
.
How do I specify that these two compound keys should be treated as a primary key
?
Edit:
Upon reading my question I thought it could use a bit more pratical description:
Givent table:
A | B
-----
5 | 1
5 | 2
5 | 3
5 | 4
5 | 5
6 | 1
We can se that no two combinations of A and B occurred. That is why I am trying to set A and B as a primary key instead of having something like:
id | A | B
-----------
1 | 5 | 1
2 | 5 | 2
3 | 5 | 3
4 | 5 | 4
5 | 5 | 5
6 | 6 | 1
which just wastes memory.