I'm trying to understand SQLObject so I've created my own schema.

Here is how it works:
At the top you have 'Type', this is a table for grouping stuff.
Then you have 'Equipment' which belongs to a Type-group.
Equipment is an abstract definition of a physical thing.
Then you have 'Items' which is a physical entity of an 'Equipment'.
A physical entity can have a status associated with it.
There are 'inv_Users' who can borrow 'Items', and this
is stored in 'Loan'.

So a Type can hold several types of 'Equipment',
and 'Equipment' can hold several 'Items'. An item
has a status, and a user can borrow an item.

Example:
Type: Computers
Equipment: 'Type: Computers, name: MacBook'
Items: 'Equipment:MacBook, name: MacBook1, barcode: 1234'
Status: 'fine'
inv_Users: 'Tor Hildrum'
Loan:
{
barcode: 1234
user_id: 'Tor Hildrum'
..
}

I'm wondering if I understood the relational mappings.
Here is my model code:

------------------------------------------------------------------------
------------------------------------------------------------------------
class Type (SQLObject):
  name = UnicodeCol(length=20)
  equipment = MultipleJoin('Equipment', joinColumn='type_id')

class Equipment (SQLObject):
  name = UnicodeCol(length=40)
  type_id = ForeignKey('Type')
  items = MultipleJoin('Items', joinColumn='equipment_id')

class Items (SQLObject):
  name = UnicodeCol(length=40)
  barcode = IntCol()
  equipment_id = ForeignKey('Equipment')
  status_id = ForeignKey('Status')
  loan = MultipleJoin('Loan', joinColumn='barcode')

class inv_Users (SQLObject):
  name = UnicodeCol(length=50)
  loan = MultipleJoin('Loan', joinColumn='user_id')

class Status (SQLObject):
  name = UnicodeCol(length=15)
  status_id = MultipleJoin('Items', joinColumn='status_id')

class Loan (SQLObject):
  barcode = ForeignKey('Items')
  user_id = ForeignKey('inv_Users')
  borrowed = DateTimeCol(default=datetime.now)
  delivered = DateTimeCol()
------------------------------------------------------------------------
------------------------------------------------------------------------

Does this look correct?

Tor

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to