
On 2-Sep-10, at 3:54 PM, Tom Murphy wrote:
Hi Everyone,
Is there a "From SQL"-type function that "restores" a range or list comprehension?
Example: Let's say I want to keep track of which episodes of a TV show I've seen. I have an SQL table, in which is a record: id (INTEGER): 30 title (VARCHAR): "The Simpsons" episodes_watched (Some data format): [1..4], [14], [18..21], [23..25]
To model this relationally, episodes_watched cannot be some kind of composite value. You need two relations, for example: CREATE TABLE tv_show ( id INTEGER NOT NULL, -- etc title VARCHAR(80), PRIMARY KEY (id) ); CREATE TABLE episodes_watched ( tv_show_id INTEGER NOT NULL, episode_number INTEGER, PRIMARY KEY (tv_show_id, episode_number) -- and ideally a foreign key constraint ); Data: tv_show (30, "The Simpsons") episodes_watched (30,1), (30,2), (30,3), (30,4), (30,14), (30,18), (30,19), (30,20), (30,21), (30,23), (30,24), (30,25) --Toby
Then, when I pull the record, in Haskell, the "Episodes Watched" is already one list: [1,2,3,4,14,18,19,21,23,24,25]
, or a series of lists that I can append together: [1,2,3,4], [14], [18,19,20,21], [23,24,25]
Note in the example that I would like to be able to store multiple ranges within a single record.
Thanks so much for any help! Tom _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners