[Solar-talk] Question about Using SolarModels to defin tables
Rodrigo Moraes
rodrigo.moraes at gmail.com
Wed Feb 6 07:51:41 CST 2008
On Feb 6, 2008 11:28 AM, Cruz, Darwin wrote:
> If i have two tables called DEPARTMENT (dept_id PK)and EMPLOYEES
> (employee_id PK, dept_id FK) where a department can have many employees, do
> i need to create 3 Solar models to define the relationship between the
> tables?
I think no. If each employee belongs to just one department, you just
need a 'department_id' column in the employee table.
> Is there a way to define indexes against the columns in a model?
Yes, defining $_index in the model, like in:
$this->_index = array(
'created' => array(
'type' => 'normal',
'cols' => 'created',
),
'department_id' => array(
'type' => 'normal',
'cols' => 'name',
),
);
> Is it possible to define a column as forigen keys to another table? I know
> that you can use the $this->_hasMany... example to link up relationships but
> it doesn't specifically create the forigen key constraint against the
> database.
Hmm, I'm not sure what forigen means, so I can't answer this one. :)
> Is it possible to set up on delete/update cascade, restrict, etc rules on
> the tables?
Not automatically. You can do this manually using Solar_Sql and SQL
queries inside your model, though.
-- rodrigo
More information about the Solar-talk
mailing list