Re:Reddit's database has only two tables
by jedberg on Monday September 03, 2012 @02:27PM
(#4471312)
You are correct that reddit has a fixed number of tables (waves hands a bit). There is one table per type, so when a new type is created, a new table is created. That rarely happens.
The reason you see those create statements in the code is for bootstrapping for open source users -- the first time they run reddit, it creates the tables.
Every "thing" (a single table) has an attribute called "type". Type is a string, and is something like "comment" or "post" or "badge".
"table.create()" doesn't create a new table, I think it creates in index on "type", so you can treat it a bit like a separate table.
Yes, it is not a "real" database. It's a key-value store, which doesn't lose data.
> "table.create()" doesn't create a new table,
if its a sqlalchemy.schema.Table, create() emits DDL for "CREATE TABLE" to the database (trust me, I wrote it). I'm guessing "table" here is some other object local to the reddit codebase.
anyway, how many "thing" tables are there total?
Having a bit of trouble parsing this, but I think you mean that the "thing/data" tables are per type, where type is "subreddit", "comment", "links". Which would indicate a fixed schema.
Can you clarify if Reddit just has a fixed number of tables? I remember seeing some "table.create()" in there but I wasn't sure what I was looking at.