What is the formula for naming link bean tables?

35 views
Skip to first unread message

Ruari Mactaggart

unread,
Mar 1, 2016, 8:53:56 AM3/1/16
to redbeanphp

This is a copy of my question here, which has had no responses. I'm pretty sure Gabor can answer this question however...

http://stackoverflow.com/questions/33776674/is-there-a-rule-to-the-name-a-link-bean-table-gets-given-in-redbean


I have a few link bean tables that were built by Redbean - each was created as a result of the following type of code;


//generates tag_video table
$tags = R::findAll('tag');
$video = R::dispense('video');
$video->sharedTag = $tags;
R::store($video);

//generates image_tag table
$image = R::dispense('image');
$image->sharedTag = $tags;
R::store($image);

//generates document_tag table
$document = R::dispense('document');
$document->sharedTag = $tags;
R::store($document);

Most of my link bean tables are named image_tag, document_tag. But I also have tag_video, which is a problem. I would prefer video_tag.

I'd like to be able to predict the link bean table names because I want to use them in JOIN's for times when I query the database directly, rather than using the ORM.

Is there a rule? Is it alphabetic perhaps? Can I insist on the 'parent' object type coming first in the table name?

gabor

unread,
Mar 3, 2016, 1:05:57 PM3/3/16
to redbeanphp
Hi,

The tables are always named alphabetically.
Unfortunately given the fact that RB strives to be zero-conf, it's not recommended to enforce a naming convention.
RedBeanPHP allows you to change most of the schema policy rules but I recommend not to do this because it will
break things and defeat the purpose of RB althoghether.

cheers
Gabor
Reply all
Reply to author
Forward
0 new messages