RedBeanPHP generates a sane and readable database schema for you. Here are the schema conventions used by RedBeanPHP:
|Field names:||Lowercase a-z, 0-9 and underscore (_)|
|Table name:||Should match bean type, a-z, 0-9|
|Primary key:||Each table should have a primary key named 'id' (int, auto-incr)|
|Foreign key:||Format: <TYPE>_id|
|Link table:||Format: <TYPE1>_<TYPE2> sorted alphabetically|
Be careful with underscores; they are used for linking tables and foreign keys. It's safe to use underscores in property names, but try not to use them in type names/tables.
To obtain the name of the table of a bean:
$beanTable = $bean->getMeta('type');
To get all tables:
$listOfTables = R::$writer->getTables();
From RedBeanPHP 3.3 on you can also sync entire database schemas across different database platforms with just one command!
RedBeanPHP Easy ORM for PHP © 2013 Gabor de Mooij and the RedBeanPHP community - Licensed New BSD/GPLv2