How to make list of foreign keys (intermediate SQL question)
posted 6 years ago
I need to create a table of subscribers to a service. At sign-up, the subscriber will choose a number of schools whose sports teams interest him or her. As there may be 1 or more, I need an SQL table construct to simulate what would be an Array or List of indeterminate length in Java or C. I'm just inexperienced enough in SQL not to know how to do this.
I would be very grateful if someone put me on the right track to using an intermediate table (that I can't think how to construct) or any other solution that can solve this problem that I can only assume is a trivial arrow in the quiver of genuine SQL guys.
It sounds like you are trying to map a many to many relationship.
One way to do this is to create an intermediate relationship table with school_id and (subscriber) id columns. Then you can do a join with the other tables to get the school name/address and subscriber info that goes with each school.