Some guidelines on databases and naming conventions

1 view
Skip to first unread message

Raoul Snyman

unread,
Nov 5, 2008, 12:50:16 PM11/5/08
to openworship development
Many thanks to Joshua and Michael for their hard work on the models.
I'm just busy cleaning up their work a little, and thought I'd better
detail what I'm doing and why.

- Moving the tables and the model classes to their own files.
I've created 2 new files in the model directory, tables.py and
classes.py. I've moved the table definitions to the tables.py file,
and I've moved the model classes to classes.py. Then in __init__.py
I've added 2 lines:
from tables import *
from classes import *

This just separates the 3 sections of the code into distinct
modules... tables are in tables.py, classes are in classes.py and the
mappings are in __init__.py

- users = members
According to a discussion we had, "User" is already used somewhere in
the Python namespace, so I'm going to stick with "Member"

- Database naming conventions
All names are lower case
Table names are plural
Primary key columns are "id"
Foreign key columns are "table_id"
Columns are not prefixed or suffixed (no "role_description", just
"description")
Columns can be multiple words separated by underscores (first_name)
Primary keys are first in the table
Secondary keys are second
Flags ("is_active") are last
Join tables are table1singular_table2plural and table names are in
alphabetical order

- Model class naming conventions
Model class names are singular
Model class names use PascalCase (no underscores to separate words)
Many to many relationship join tables don't need models
Models should inherit from the BaseModel class I've added in there

That's about all I have to say for the moment. I'm busy working on
this at the moment, and once I'm done I'll commit it and folks can
have a closer look at the code.

Raoul Snyman

unread,
Nov 6, 2008, 12:00:30 PM11/6/08
to openworship development
> That's about all I have to say for the moment. I'm busy working on
> this at the moment, and once I'm done I'll commit it and folks can
> have a closer look at the code.

I've committed the code, though I didn't revamp it completely. Once we
have had a meeting on Saturday, we can clear up a few things that need
to be clarified in order to continue with the project.
Reply all
Reply to author
Forward
0 new messages