If I was to extend the blog demo to be multi-user, e.g. Blogger A stored their posts in table “post_A” and blogger B’s posts were stored in table “post_B”, how could I override the Post model at construction to set the tableName to A or B as necessary?
imehesz is right, you most likely don’t want to do that except you really have a very good reason. It would break all rules on how to model your database tables. If you still think, it’s necessary, try to google for data model tutorials, you’ll find a lot of information out there.
OT: imehesz, how do you create your nice ASCII arts? Always wondered if there’s an editor and could find only one: JavE .
Well, I am not actually making a blog. I was just using that as an easy analogy. I will have a lot of records for each person and for performance don’t want to have to deal with database sharding of one giant table. I would prefer to simply put different tables on different servers.
Regardless of the reason, and whether or not its a good idea, is it even possible?
There was also a topic on sharding, if that is what you want. Try the forum search.
If you want something different, my bet is that you cause yourself a lot of headache if you try to implement such a feature with ActiveRecords as practically none of the advanced features will work. E.g. you can’t use JOINs to fetch related data if the related data is shattered across different tables.