Re: Dumb Database schema / EOModeler questions...

ThrinathJ <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi,

     I wonder, i need some more time to answer your first part of the req.
But regarding the second part i.e. story fetching i guess the following will
help you,

STORY:
StoryId - PK
CreatorId - FK 

 RelationShips:
 Creator - CreatorId --> UserId(UserId PK  of USER)

so when you want to fetch the stories written by the friends of user, form a
fetch specification such that it forms like,

select * from STORY where CreatorId in(select User2ID from FRIEND where
User1ID = the main user )

build the qualifier regardingly.

Build a EOKeyValueQualifier which is framed like "User2ID" equals "User1ID".
similarly create a  new EOKeyValueQualifier  which is framed like
"approvedByEditor" equals "true". Then from the userslist just use the
filterArrayWithQualifier using the final EOAndQualifier. This will give you
the list wanted.

I guess the DB you are using is oracle. if so, why did you choose storyId
etc. to LONGINT. will the Int not suffice your requirement?

I guess this leads to no duplication, 'coz the  userids we are using are
anyhow the PKs of the USER table. Dont forgot to have a instance variable
for the USERID in USER table in EOModel.

Regards,
Thrinath.J


Numair Faraz wrote:
> 
> Hi all,
> 
> I'm working on a "social news" application written in WO, and am
> currently in the process of modeling my database (we're going to use
> FrontBase).  As I am not an expert at database modeling / creating
> scalable solutions - embarrassingly bad, to tell you the truth - I
> wanted to get some perspectives from the people on the list regarding
> what they'd do.  My proposed implementations seem awfully simplistic,
> which leads me to believe that they won't scale ...
> 
> Basically, we have three tables: USER, FRIEND, STORY; what I want to
> figure out is...
> 
> - What is the most efficient way to set up the FRIEND table?  Assuming
> that when a user first asks to be a friend of another user, the
> connection remains pending until the other user confirms (thus meaning
> all USER.friends relationships are bi-directional), should I have
> things set up so that FRIEND is as such:
> 
> FRIEND
> ======
> friendId - LONGINT, Primary Key
> userId - LONGINT, Foreign Key
> user2Id - LONGINT, Foreign Key
> approved - BOOLEAN
> 
> owner - relationship to USER: FRIEND.userId + USER.userId
> friend - relationship to USER: FRIEND.user2Id + USER.userId
> 
> .. with an approval by the other user meaning that another FRIEND
> entry for their relationship?  I am assuming that two transactions /
> table entries are very inefficient, and that this will cause problems
> for me later on, but that's the best solution I could think of.
> 
> Now, assuming that we have USERs and USER.friends .. Say we have the
> following STORY table:
> 
> STORY
> ======
> storyId - LONGINT, Primary Key
> userId - LONGINT, Foreign Key
> body - CLOB
> approvedByEditor - BOOLEAN
> 
> author - relationship to USER: STORY.userId + USER.userId
> 
> .. How would one fetch all of the stories posted by the friends of a
> user in the most efficient manner?  My avoidance of reading a proper
> database modeling book has caused me to be incapable of even beginning
> to figure this out, let alone figure out how I would model it in
> EOModeler (blame the US education system...).  I also need to figure
> out how to fetch an array that contains both a user's friend's
> stories, and stories that are marked approvedByEditor, with no
> duplication; again, no clue how I would do this in EOModeler (which I
> hadn't used in about 4 years, until this week)...
> 
> Hope you guys can help ...
> 
> Numair
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev
> 
> 

-- 
View this message in context: http://www.nabble.com/Dumb-Database-schema---EOModeler-questions...-tf2490251.html#a7108335
Sent from the WebObjects-Dev mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.