Modification in LiveUser SQL for Perm and Auth
| From: | Bertrand Mansion | Date: | Thu, 10 Oct 2002 12:32:28 +0000 |
| Subject: | Modification in LiveUser SQL for Perm and Auth | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-9991@lists.php.net to get a copy of this message | ||
Hi,
I would like to make some modifications in the SQL for the liveuser tables
but they might not be backward compatibles so take this message as a
suggestion only and tell me what you think.
1. I would prefer to use uppercase for field and table names:
This is because I already had trouble with Oracle converting all names to
uppercase by default, so I took the habit to uppercase everything.
2. Use a prefix for liveuser tables:
This is useful to know that the tables relate to a certain package.
It's already the case, we use 'liveuser_...' but I would suggest
something shorter like 'LU_...'
3. Use a table prefix for table fields:
I found this particularly useful not to mix field names between tables in
SQL queries. I know it's possible to use (1) TABLE.FIELD or (2) A.FIELD
when an alias is defined for TABLE A, but this still make long queries
and, like in German, you have to read the whole sentence to get the
meaning. My solution is to use for example ARNA_DEFINE_NAME for the area
define name of the table AREA_NAME.
4. Use PK and FK to differenciate Primary Keys and Foreign Keys.
For instance, ARNA_PKAREA_NAME for AREA_NAME table primary key and
anywhere else RIGHT_FKAREA_NAME to know this field is a foreign key
related to a PKAREA_NAME in another table.
5. Use unsigned int() types where possible. This allow for more numbers and
less disk usage as we don't need negative values.
6. Use varchar() instead of char() where char is not necessary.
Varchar() takes less disk usage.
7. Use index where they could speed up queries.
Note that I am not a DB expert, these are just habits I took which I found
really useful on the longer run. Still, I am quite open to other
suggestions.
TIA,
Bertrand Mansion
Mamasam