Re: Saving entities problem [SOLVED]
Re: Saving entities problem [SOLVED]
- Subject: Re: Saving entities problem [SOLVED]
- From: Art Isbell <email@hidden>
- Date: Tue, 29 Jul 2003 10:01:13 -1000
On Tuesday, July 29, 2003, at 06:40 AM, Jevon Hills wrote:
Then (as I understand it) in my code if I have an Application obj
(anApp) and wish to add a User obj (aUser) to it i write the
following: anApp.addObjectToBothSidesOfRelationshipWithKey(aUser,
"pubUser");
This will essentially maintain the join for me.
Correct.
myClass
{
pubUser aUser;
pubApplication anApp;
pubPermission aPerm;
EOEditingContext editingContext;
aUser.addObjectToBothSidesOfRelationshipWithKey(anApp,
"pubApplication");
aUser. addObjectToBothSidesOfRelationshipWithKey(aPerm,
"pubPermission")
editingContext.saveChanges()
}
Looks good to me, but does it work ?-)
----------------- --------------------
----------------
|pubUser | |pubUserAppPerm |
|pubApplication|
|---------------| |------------------|
----------------
|pubUserID PK |==============|pubUserID FK
|===============|pubAppID PK |
----------------- |pubAppID FK |
----------------
|pubApps V| |pubPermID FK |
|pubUsers V|
|pubPerms V| |------------------|
|pubPerms V|
|pUserAppPerms | |pUser |
|pUserAppPerms |
----------------- |pApp |
----------------
|pPerm |
--------------------
=
=
=
=
=
-----------------------
|pubPermission |
-----------------------
|pubPermissionID PK |
-----------------------
|pubApps V|
|pubUsers V|
|pUserAppPerms |
-----------------------
I have implemented the exact same schema for the exact same purpose
but with one difference: if a user had the authority to use an app but
did not have a permission associated with that authority, the user had
"default" access rights. So instead of modeling a 3-way many-to-many,
I modeled a 2-way many-to-many (User <<-->> Application). The
UserApplication join entity had an optional to-many relationship to
Permission (a user could have multiple levels of access to an
application). UserApplication was not an abstract entity and did have
an associated custom EO class, so I removed the flattened relationships
from User and Application to UserApplication and made the to-one
relationships from UserApplication to User and Application class
properties.
So when a user enters an account and password, I fetch User qualifying
on account and password. If a User object is fetched, the account and
password were correct, so I fetch UserApplication qualifying on the
User I just fetched and the Application object representing the current
app. If a UserApplication object is fetched, the user has the
authority to use the app in its default mode. I then ask the
UserApplication object for its permissions. If any exist, I set the
mode of the application to be appropriate for the permissions.
I considered modeling this as you did, but I'd have to have a
permission object that each user would have for each application. That
would have worked, but a little less DB space is used by not having any
permission object for a default access level.
Art Isbell
AppleCare Enterprise Services Technical Support
http://www.apple.com/services/technicalsupport/
+1-808-591-0836
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.