Dependency

View: New views
5 Messages — Rating Filter:   Alert me  

Dependency

by comfortablementeadormecido :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I keep playing around with metastorage and another thing came to my
attention.

There is no way to set a dependency between objects. For instance,
imagine you have the entities State and City, when you delete a state
every city for that state shoud be deleted in order to mantain
consistency with the data in the City table (many of them would retain
an id to a deleted State). This is obviously easy to do by setting a
delete method for the cities and state and another method for the
state which would get its collection, call the delete method in each
city and then call delete for the current state or a similar algorithm.
But i think it could be considered for a future release that when you
set the collection relation you could set such things so you don't end
up with two functions to delete a state (the standard and the custom one).

What do you think?





------------------------ Yahoo! Groups Sponsor --------------------~-->
See what's inside the new Yahoo! Groups email.
http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/metal-dev/

<*> To unsubscribe from this group, send an email to:
    metal-dev-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




Re: Dependency

by mlemos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

on 07/12/2006 03:12 PM comfortablementeadormecido said the following:

> I keep playing around with metastorage and another thing came to my
> attention.
>
> There is no way to set a dependency between objects. For instance,
> imagine you have the entities State and City, when you delete a state
> every city for that state shoud be deleted in order to mantain
> consistency with the data in the City table (many of them would retain
> an id to a deleted State). This is obviously easy to do by setting a
> delete method for the cities and state and another method for the
> state which would get its collection, call the delete method in each
> city and then call delete for the current state or a similar algorithm.
> But i think it could be considered for a future release that when you
> set the collection relation you could set such things so you don't end
> up with two functions to delete a state (the standard and the custom one).
>
> What do you think?

This is already done. When an object is deleted, it is removed from any
collections that it used to belong. If there are any objects with
reference variables pointing to the object being deleted, those
reference variables are set to NULL.

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/metal-dev/

<*> To unsubscribe from this group, send an email to:
    metal-dev-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Re: Dependency

by comfortablementeadormecido :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Yes the references are nullified indeed, but I ment a cascading
removal of elements that are dependant of the existance of a certain
object.
Using the same example as before: If each State has a Collection of
Cities, when a State is removed, and if the existance of a City
depends on the existance of the corresponding State, then every City
for that state should be removed as well.
Currently the references to the state are set to NULL (by means of
this query = "'UPDATE city SET state=NULL WHERE
state='.strval($this->id)") but then every city that has its State
attribute set to NULL should be removed one by one. Besides, the
persistance of objects with references to other objects set to null is
invalid as a default behaviour. By means of deleting a State you would
be settig every city for that State in an invalid 'situation' (the
word 'state' would have been confusing :p ).

Perhaps I'm getting this all wrong, please correct me if I am. As I
said before I really put a lot of faith in this project as I think it
would be a great help in my job but I still cant convince myself that
the application is fully capable of satisfying my needs. I hope that
by means of questions liike this I am helping clarify and possibly
correct the functionality of the project and not just annoying you.

Thanks for your time and dedication,

Matías

--- In metal-dev@..., Manuel Lemos <mlemos@...> wrote:

>
> Hello,
>
> on 07/12/2006 03:12 PM comfortablementeadormecido said the following:
> > I keep playing around with metastorage and another thing came to my
> > attention.
> >
> > There is no way to set a dependency between objects. For instance,
> > imagine you have the entities State and City, when you delete a state
> > every city for that state shoud be deleted in order to mantain
> > consistency with the data in the City table (many of them would retain
> > an id to a deleted State). This is obviously easy to do by setting a
> > delete method for the cities and state and another method for the
> > state which would get its collection, call the delete method in each
> > city and then call delete for the current state or a similar
algorithm.
> > But i think it could be considered for a future release that when you
> > set the collection relation you could set such things so you don't end
> > up with two functions to delete a state (the standard and the
custom one).

> >
> > What do you think?
>
> This is already done. When an object is deleted, it is removed from any
> collections that it used to belong. If there are any objects with
> reference variables pointing to the object being deleted, those
> reference variables are set to NULL.
>
> --
>
> Regards,
> Manuel Lemos
>
> Metastorage - Data object relational mapping layer generator
> http://www.metastorage.net/
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/metal-dev/

<*> To unsubscribe from this group, send an email to:
    metal-dev-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




Re: Re: Dependency

by mlemos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Sorry for the delay.

on 07/17/2006 02:18 PM comfortablementeadormecido said the following:

> Yes the references are nullified indeed, but I ment a cascading
> removal of elements that are dependant of the existance of a certain
> object.
> Using the same example as before: If each State has a Collection of
> Cities, when a State is removed, and if the existance of a City
> depends on the existance of the corresponding State, then every City
> for that state should be removed as well.
> Currently the references to the state are set to NULL (by means of
> this query = "'UPDATE city SET state=NULL WHERE
> state='.strval($this->id)") but then every city that has its State
> attribute set to NULL should be removed one by one. Besides, the
> persistance of objects with references to other objects set to null is
> invalid as a default behaviour. By means of deleting a State you would
> be settig every city for that State in an invalid 'situation' (the
> word 'state' would have been confusing :p ).
>
> Perhaps I'm getting this all wrong, please correct me if I am. As I
> said before I really put a lot of faith in this project as I think it
> would be a great help in my job but I still cant convince myself that
> the application is fully capable of satisfying my needs. I hope that
> by means of questions liike this I am helping clarify and possibly
> correct the functionality of the project and not just annoying you.

If you want to remove cities that belong to a state, you can delete the
city objects one by one and they automatically will be removed from the
collections they they belonged.

Cascaded deletes can be dangerous. Even if the database supports them, a
simple mistake may wipe the whole database. I never used them. As a
matter of fact, usually I have a removed flag in objects that I may want
to check past information later, rather than actually delete them.

That does not mean it cannot be done. It means it can be done with
proper care. I have just added it to the todo list now so I can
implement it when I have more time.

http://www.meta-language.net/metastorage-progress.xml

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/metal-dev/

<*> To unsubscribe from this group, send an email to:
    metal-dev-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




Re: Dependency

by comfortablementeadormecido :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you for your attention Manuel.

Regards,
Matías

--- In metal-dev@..., Manuel Lemos <mlemos@...> wrote:

>
> Hello,
>
> Sorry for the delay.
>
> on 07/17/2006 02:18 PM comfortablementeadormecido said the following:
> > Yes the references are nullified indeed, but I ment a cascading
> > removal of elements that are dependant of the existance of a certain
> > object.
> > Using the same example as before: If each State has a Collection of
> > Cities, when a State is removed, and if the existance of a City
> > depends on the existance of the corresponding State, then every City
> > for that state should be removed as well.
> > Currently the references to the state are set to NULL (by means of
> > this query = "'UPDATE city SET state=NULL WHERE
> > state='.strval($this->id)") but then every city that has its State
> > attribute set to NULL should be removed one by one. Besides, the
> > persistance of objects with references to other objects set to null is
> > invalid as a default behaviour. By means of deleting a State you would
> > be settig every city for that State in an invalid 'situation' (the
> > word 'state' would have been confusing :p ).
> >
> > Perhaps I'm getting this all wrong, please correct me if I am. As I
> > said before I really put a lot of faith in this project as I think it
> > would be a great help in my job but I still cant convince myself that
> > the application is fully capable of satisfying my needs. I hope that
> > by means of questions liike this I am helping clarify and possibly
> > correct the functionality of the project and not just annoying you.
>
> If you want to remove cities that belong to a state, you can delete the
> city objects one by one and they automatically will be removed from the
> collections they they belonged.
>
> Cascaded deletes can be dangerous. Even if the database supports them, a
> simple mistake may wipe the whole database. I never used them. As a
> matter of fact, usually I have a removed flag in objects that I may want
> to check past information later, rather than actually delete them.
>
> That does not mean it cannot be done. It means it can be done with
> proper care. I have just added it to the todo list now so I can
> implement it when I have more time.
>
> http://www.meta-language.net/metastorage-progress.xml
>
> --
>
> Regards,
> Manuel Lemos
>
> Metastorage - Data object relational mapping layer generator
> http://www.metastorage.net/
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/metal-dev/

<*> To unsubscribe from this group, send an email to:
    metal-dev-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



LightInTheBox - Buy quality products at wholesale price