Welcome, Guest
Username: Password: Remember me

TOPIC: [FAQ] Table Naming conventions

[FAQ] Table Naming conventions 22 Nov 2011 12:56 #547

  • giori
  • giori's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 14
  • Karma: 6
Hi to everybody,

usually I group customer made tables in joomla together with a customer prefix like:

jos_joomla_standard_tables
...
jos_customer_project1_table1
jos_customer_project1_table2
jos_customer_project2_table1
jos_customer_project3_table1
...

so that I see them with one glimpse in phpmyadmin. Unfortunately there is an automatism here that strips the table names to jos_project1_table1 etc. What would be the best way to group tables of different projects together, so that they will not be scattered inside all the other joomla and extension tables? Thanks!
The administrator has disabled public write access.

Re: Table Naming conventions 22 Nov 2011 13:11 #548

  • twev
  • twev's Avatar
  • Offline
  • Senior Member
  • Posts: 62
  • Thank you received: 15
  • Karma: 6
I think Cook will do that automatically. I have a project named haarecords and I created some tables called area, clubs, groups, records. When I downloaded and installed the project, the following tables were created:
jos_haarecords_area
jos_haarecords_clubs
jos_haarecords_groups
jos_haarecords_records
So they are all nicely grouped together in a database editor.

In your example if you name your project customer_project1 and name your tables table1 and table2 I think you will get what you are looking for.
The administrator has disabled public write access.

Re: Table Naming conventions 22 Nov 2011 13:17 #549

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Yes, I often use this method too.

Unfortunatly, since Joomla 1.6, there is somewhere we cannot anymore do this (not for DB, but in Models or controllers. I don't remember where) so, to avoid changing the aliases depending of the context, I prefered to have a common alias everywhere (TABLE = VIEW = CONTROLLER = MODEL, ....). So I had to forbid the use of '_' in table aliases and layouts aliases. In first versions of Cook it was possible.

For example, what I remember, modal pickers lacks when you want to reach a layout named with a '_'.

Another very important reason, I had to limit, is for foreign keys :
$row->fkuser     // Is a foreign key
$row->_fkuser_name    // Is the joined value behind fkuser linked table ('name' field)

If you name a field "_fkuser_name" for instance, it will conflicts.

Same idea for the tables aliasing in SQL queries.
Coding is now a piece of cake
Last Edit: 22 Nov 2011 13:19 by admin.
The administrator has disabled public write access.

Re: Table Naming conventions 23 Nov 2011 14:30 #573

  • giori
  • giori's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 14
  • Karma: 6
twev,

thank you for your suggestion, but as admin suggests, this no longer works in the current release of Cook.

If I create a project named CUSTOMER_PROJECT the project name will be reduced to CUSTOMERPROJECT, the component will be named com_customerproject and tables jos_customerproject_table instead of jos_customer_project_table as of Joomla standard. But it's not a big deal, I can live with that.
The administrator has disabled public write access.
Time to create page: 0.069 seconds

Get Started