CREATE TABLE feedGroupFeed (
    feedGroupId TEXT,
    feedId TEXT,
    PRIMARY KEY (feedGroupId, feedId),
    FOREIGN KEY (feedGroupId) REFERENCES feedGroup(id) ON DELETE CASCADE,
    FOREIGN KEY (feedId) REFERENCES feed(id) ON DELETE CASCADE
);

CREATE INDEX feed_group_feed_feedGroupId_index ON feedGroupFeed(feedGroupId);
CREATE INDEX feed_group_feed_feedId_index ON feedGroupFeed(feedId);
CREATE INDEX feed_group_feed_feedGroupId_feedId_index ON feedGroupFeed(feedGroupId, feedId);

addFeedToGroup:
INSERT OR REPLACE INTO feedGroupFeed(feedGroupId, feedId)
VALUES (?, ?);

removeFeedFromGroup:
DELETE FROM feedGroupFeed WHERE feedId = :feedId AND feedGroupId = :feedGroupId;

removeFeedFromAllGroups:
DELETE FROM feedGroupFeed WHERE feedId = :feedId;

removeAllFeedsFromGroup:
DELETE FROM feedGroupFeed WHERE feedGroupId = :feedGroupId;

deleteAll:
DELETE FROM feedGroupFeed;

groupIdsForFeed:
SELECT feedGroupId FROM feedGroupFeed WHERE feedId = :feedId;
