SQLite Forum

How to relate a row with more than one topic? See example
Login
> And which column format does SQLite not support?

Don't know about MYSQL, but in PostgreSQL for example you could have an array field to hold all the topics

`
create table quotes (
    quote_id integer not null primary key,
    quote text not null,
    topic_ids integer[]
);
insert into quotes values (1, 'A successful man is a fall in love man.', array[1, 2, 3]);
`

But the only advantage of that would be 1 less table and a lower overall record count, which doesn't really help anything. You couldn't make them official foreign keys, updates would be harder, indexing going from topics to quotes would be harder, etc.

So, as people have recommended, it would be a lot better for the normal

`
create table quotes_to_topics (
    quote_id int not null references quotes,
    topic_id int not null references topics,
    primary key (quote_id, topic_id)
) without rowid;
create index topics_to_quotes_idx on quotes_to_topics (topic_id, quote_id);
`