vendredi 11 mars 2016

How to create lines/stops relationship

I'm not a database expert and I'm simply building a prototype app, so nothing really important.

Anyway, the app is about a subway: this subway has many lines and sometimes some stops are shared between lines (so, for example, stops 3 and 4 are stops of lines 2, 7 and 9).

So, I made up a SQLite stops table:

    +---------+-------------+------+
    | Field   | Type        | Auto | 
    +---------+-------------+------+
    | id      | integer     | YES  |
    | name    | varchar(20) | NO   |
    | lines   | ?           | NO   |         
    +---------+-------------+------+

What's the best way to deal with shared stops? My idea was to create a lines table and then in the lines field of the stops table put a comma separated list of lines.id. I don't know why, but I feel there could be a better way.

Any suggestion is appreciated, and sorry for the really noob question.

Aucun commentaire:

Enregistrer un commentaire