Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation - How should database table and column names be written #269

Open
shoulders opened this issue Oct 19, 2020 · 3 comments
Open

Comments

@shoulders
Copy link

shoulders commented Oct 19, 2020

Table names

In the Joomla database all the table names are in snake_case and by the looks of this is how it will always be, However this is not in the Joomla Documentation anywhere, at least not that I have found and I think it should be added for clarity.

Column Names

Most column names in joomla and 3rd party extension are snake_case but some are camelCase/dromedaryCase.

There is no official documentation on how one should name a column including how and when column comments should be added. This should be added to the documentation so I know which style to use for my database.

One thing to watch out for in fixing the snake_case to camelCase naming, is some of those are long-standing names in the database architecture. There has been resistance to fixing those since it will break 3rd party extensions.
https://issues.joomla.org/tracker/joomla-cms/13415

This is exactly the why I need clarity for the table names.

On the first post under the 4. Parameter Variable name I have written a small worked example of this:

Params

On a related issue, how would this change the names/keys of variables in $params, should they follow the same syntax as the table names for consistency? this needs to be addressed at the same time. And why this matters is you tend to define all of these parameters in your extensions XML files and you might have direct table names and values from parameters being looked up.

I can expand on this if anyone wants any further info from me.

This issue came about when I was making my reference extensions and found these standards missing.

thanks

Other Database related info for the database documentation

  • I know that date fields should now use Null value rather than 000:00:00 00:00 see here
@zero-24
Copy link
Contributor

zero-24 commented Nov 3, 2020

Hi,

i'm just out of the production department meeting where we discussed this issue here. We acknowled the thing issue but for now there are no plans to add and implement a rule guide for extensions beyond that what we already have and can be found in the docs wiki for example:

https://docs.joomla.org/Category:Beginner_Development
https://docs.joomla.org/J3.x:Developing_a_MVC_Component/Using_the_database/en

As Joomla 4 gets closer to a realease that docs get updated to the Joomla 4 style to build components.
As for the specific issue with columnames we agreed to recommend lowercase and underscores as that allows you to support different databases, but thats not a hard rule we can nor want to enforce on any extension developer.

A general recomendation for any new person would be to check the extensions supplied by the core, but i clearly want to mention here that what we do there is a example and no official rule or such kind of things and we also know that the core extensions are not perfect nor always consistend.

I hope that helps you, i know thats not the answear you wanted to hear but right now our main focus is to get Joomla 4 out and we only have limited resources. :)

@shoulders
Copy link
Author

@zero-24 Thanks for mentioning this. I also 100% appreciate that Joomla 4 is a priority

The guides have no information in this, hence my boggle.

Maybe a note about this issue on the relevant page saying that the joomla core team is aware of this and that currently there is no right answer at the moment

I could also write a real world example A and B (snake_case and dromedaCase) going down from the database column all the way to using it in a template and a quick note saying that this will not violate current code syntax rules as currently both methods are excepted. I will do some examples and post them here

Either or both of these will stop people hunting for an answer and the Joomla team can point people to the relevant paragraph (or here).

@zero-24
Copy link
Contributor

zero-24 commented Nov 3, 2020

That would be great. The wiki is a media wiki so you can create a account and add some good examples with recomendations would be very great. I'm happy to help with the setup where needed just contact me.

That should work as a starting point
https://docs.joomla.org/JDOC:How_to_Contribute_to_Joomla!_Documentation

When done please send me your username so I can ask you to be promoted so you can bypass the spam restrictions. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants