If I have a relationship between two tables like this:
CREATE TABLE parent (id INT NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE child (id INT NOT NULL, parent_id INT,
PRIMARY KEY (id),
FOREIGN KEY (parent_id) REFERENCES parent(id)
);
And I want to find all of the rows in the child table that are referencing one row in the parent table, is it faster to:
- Simply query the child table and return all that match the id of the parent row
- Store a comma separated list of ids in a column in the parent table
- None of the above