Closed unpairedbracket closed 8 years ago
I'm happy to make a films2 database, and effectively start the DB from scratch, but as you say, it's the data migration that is a lot of effort.
I made a pretty picture, mostly for my reference if I do end up doing this, and because I have work to do so I had to find something else to do instead.
Very nice. Perhaps worth including things like the current user id etc. We will still need this for logging in. Happy to give you an account on the pis with access to the DB if you like.
Ah, yeah, of course. I'd move all the user settings, etc. into the users table too, and possibly the film info that's currently put in selected_films by imdb.php into the films table. Was just mostly including the fields necessary for all the linking to work etc. Sounds good - typical that I think to do this right at the point where I've got the most work I've had all term though... I'll look further into it at some point next week once I've got all these sheets out the way.
Some of the php that handles database interaction could be made cleaner if we restructure the database somewhat. For example if we were to add nice autoincrementing primary keys to our
users
andfilms
tables, and move theproposed_by
andvetoed_by
columns into aproposals
table that contains a user id, a film id and a booleanis_veto
field, we could use the SQL querySELECT films.* FROM films INNER JOIN proposals ON films.id = proposals.film_id INNER JOIN users on users.id = proposals.user_id GROUP BY film_id HAVING NOT SUM(is_veto AND NOT attending);
to return all films not currently vetoed by a non-attender, and even generate the film list by stickingORDER BY RAND() LIMIT 5
onto the end of that query.If I were making the db from scratch now I'd also replace the
selected_films
table with one that just joins into thefilms
andtimings
tables, and have, say, 5 rows linking film ids to each timing row. We might even be able to insert into it directly from the above film selection query, just by using aSELECT INTO
query. Then when someone casts their vote we could add 5 rows to avotes
table that links the selected films to the user who's voted and has an int field for the position they've put it in. That would allow us to ditch theincoming_votes
table and keep a record of all the voting that's happened - we'd just be able to do a SELECT by film night id (joiningvotes
toselected_films
) and show that set of results.I realise implementing this and migrating all the data over will be a lot of work and it may or may not be practical to do this at any point, but if there's going to be a time to do it, it'll be over the holidays when we don't need to be in production for a few weeks. If we do decide to do it, I'm happy to take a copy of the db and do the grunt work myself in the holidays, so we can return next term with a shiny new database and less horrible database management code.