I have one table:
CREATE TABLE teams (
id INTEGER PRIMARY KEY,
member_count INTEGER NOT NULL
);
I have another table:
CREATE TABLE members (
id INTEGER PRIMARY KEY,
team_id INTEGER,
member_number INTEGER
FOREIGN KEY (team_id) REFERENCES teams (id)
);
I want member_number to have a value that is between 1 and member_count (inclusive). I know that I need to use the check constraint here, but I don't know how to do it using a column of another table. How do I do that?