AHA!.. so ... Im starting to understand something... The WorkDay you suggest to add, will keep track of each single day, so that table will grow up each day an employee register for a turn.

lets suppose the admin, based on a properties file, generate the turns, from mon-fri on a 3hrs/turn for 12hrs /day, that give us a 4 turns per day. Sat from 10 till 7 and sun from 10 - 4. So on the Turn will go:
ie.

id endDateTime idealEmployees maxEmployees minEmployees startDateTime
1               12::00                          6                               
        8                                       4                               
        09:00
2               15:00                           6                               
        8                                       4                               
        12:00
3               18:00                           7                               
        8                                       6                               
        15:00
4               21:00                           6                               
        7                                       5                               
        18:00
5               13:00                           8                               
        9                                       6                               
        10:00
6               16:00                           7                               
        10                                      6                               
        13:00
7               19:00                           7                               
        10                                      6                               
        16:00
8               13:00                           5                               
        6                                       4                               
        10:00
9               16:00                           4                               
        5                                       3                               
        13:00




and on WorkDay will go.

id              dayOfWeek               idTurn                          
startingDateTime                
1               Monday                   1                                      
        09:00
2               Monday                  2                                       
        12:00

and so on...
isn't it?

then when a employee register for a turn he will select a day, lets say Tuesday, based on a calendar, then I will fetch all the turns for tuesday and display them on the "tabl, form" im not worrying about how to displaying now, (Im following your advice David, :P),

and he will select the turn 3 lets say. so that;s it from 15:00 to 18:00, (im not considering validating that it has the required employees now and other stuff, lets asume he can select that one).. so when he will click on the submit button... what I will have to do is.

I have the employee now, (he logged in already) I have the Date and turn he wants to work at, so I will have to add to EmplyeeTurn .............................


OMG got confused again....

im gonna take a break.....

I hate db!.

thanks

Gus


On Oct 3, 2008, at 2:26 PM, David Avendasora wrote:


On Oct 3, 2008, at 2:58 PM, WebObjects wrote:

Sorry about the reply, not reply all.

ok so this is what I did.

I created the Join table EmployeeTurn as a normal Entity, ad the atributes, and when adding the relationship I just set the FK normally. I did this becuase if I just creat the entities Employee and Turn, and then I made the relatonship, and allow EOModel to create the JoinTable it will put in the JoinTable the idEmployee as PK also idTurn. and if Im gonna add records to that table, then this case cant be added

EmployeeTurn:
id                      idEmployee                      idTurn          
creationTimeStamp
1                               1                               1               
                
2                               1                               1               
                

this case is the case when a Employee regsitrer for turn 1 today, and in a few days he sets again for turn 1 for the next week..

I'm figuring that if you have zero or more Turns per WorkDay. Next Monday is a new WorkDay, so it has new instances of Turn. I'd see it more like this:

EmployeeTurn:
id                      idEmployee                      idTurn          
creationTimeStamp
1                               1                               1               
                
2                               1                               28

You would not be reusing Turns as they can change. What if in 5 months the admin wants 6 2-hour Turns instead of 4 3-hour Turns?

Both Turns are Mondays, and could be the same time on a Monday, but because they are on different WorkDays, they are different instances of Turn.

You could automate the creation of Turns based on information in a properties file, or create a set of WorkDays and Turns that are templates and each new WorkDay and set of Turns could be generated based on those templates. If the admin wants to change something, he just changes it before generating the next set of WorkDays and Turns. No reprogramming.

If you lock yourself into one Turn that is for ALL Mondays, what happens when the Employees want to sign up more than a week in advance?

The relationship you have between WorkDay and Turn in your model is backwards. A WorkDay will have many Turns. A Turn will belong to One WorkDay.

WorkDay <->> Turn

Dave


did I made good? doing this? or didn't I understand something what you explain me.


Gus

        
<TurnsControl.eomodeld.zip>
On Oct 3, 2008, at 1:08 PM, David Avendasora wrote:

Keep the replies on the list, please.

On Oct 3, 2008, at 1:19 PM, WebObjects wrote:

Hello
So let me review:

You have Employees that will be signing up for Turns to work, right? The thing you need to know about the Employees is just their name (worry about how they log in later). The thing you need to know about the Turns are What the starting date & time, the ending date and time.

For the first. Yes, I have Employees that will sign up for Turns to work on.
2nd. I was thinking to log in with the email address.

Right, but that's extra right now. How they log in is separate from the core business function of your application. Keep the number of things to think about small for now.

3rd. Normally,

Stop. Normally? You can't model "Normally". If the Turns are variable at all, then you should work from the assumption that they all can change.

ie. Monday has 4 Turns, startinng from 9am, and ending at 9pm, so we have a 3 hours /turn. THis turns are already set by the admin. for each day. ,.. but actually they are the same, from mon-fri, but on sat and sun are different.... maybe this info is useful.

This is exactly what I was talking about above. If Saturday and Sunday are already different, what about holidays?


Key questions:

1) Can more than one Employee sign up for the same Turn?
2) Are Turns the same (same start and end) from day-to-day? For each day of the week?
3) Can turns span two days?
4) Are any of these assumptions likely to change?


1. Yes. thats why I have( was thinking to have) maxEmployee attribute in turns

Okay, but I'm guessing that the max will very depending upon the day. Not every turn for all days will have the same maxEmployees, right?

2. Opps as I wrote, maybe I wasn't clear in the last mail. From mon - fri they are exactly the same. but from sat and sun they change.
3.I dunno what you mean.. If a turn can be in 2 days,??

Would a turn span from 10pm to 2am the next day? If so, you can't just store a date, you have to store a date-time.

4. Yes, depending on the admin, ie. if he sees that in the 3rd turn of wed the store its really full, he will need more employees working on that turn. and so on.

Okay, so you have to model the application to allow for the changes.

Ok so. So far..
NO PK for eMail attribute. Just set it to Unique in the db schema. GOT IT. :D

What is code? What is maxEmployee?


code its the numerical code of the turn, for mon the code will be 01 and the first turn will be 01 so the whole code will be 0101, for the second turn of monday will be 0102, and so on.. the same for the rest days, depending on the day. ie. Friday second turn will be 0502.

maxEmploeyy its the maxNumber of employes a turn may have.... mmmm.. maybe I should have a min as well?

Yes, and maybe an "ideal" so that the manager can say "Ideally I'd like 2, but I'll accept either 1 or 2 or 3" and the Employee can know that if the ideal has been reached, then their request may be denied, or something like that.

what you think?

Employee <->> EmployeeTurn <<-> Turn <<-> WorkDay

Employee
id
email
name
password

Turn
id
startDateTime
endDateTime
minEmployees
idealEmployees
maxEmployees

EmployeeTurn
id
idEmployee
idTurn
creationTimestamp


WorkDay
id
dayOfWeek
startingDateTime


This gives you the ability to get a WorkDay, and all of the turns() that are related. Each Turn then has employeeTurns() that give you a list of all the employees signed up for a turn, and when they signed up. You could also add an EmployeeTurnStatus table that would keep track of various statuses such as pending, approved, rejected, etc.

I'd plan on dynamically creating the "code" instead of setting it as a value in the DB. You can easily take the day of the week and the index of the Turn in the sorted array of Turns to create this on the fly, and if you change the Turns time or day it will automatically update.

The "code" for a given EmployeeTurn can simply be gotten by calling turn().code() so you don't need it on the EmployeeTurn entity.

Added bennifit is that when the Admin is setting up the Turns, you can easily validate the start and end times by comparing them to the WorkDay startingTime and the start and end times for other Turns that have been already created.

As far as most days being the same, you could easily setup a properties file that has that info in it and then add a button that creates the WorkDays for a week based on the values in the properties file, that way if you want to make Fridays have different Turns too, you don't have to change code, just open the properties file.

On a side note, this is the type of exercise that I love using D2JC for. You can make you model, run it, try it out, see where things are weird, change the model, run it again. No UI code or refactoring required.


Dave





Gus



On Oct 3, 2008, at 10:35 AM, David Avendasora wrote:


On Oct 3, 2008, at 11:00 AM, WebObjects wrote:

Hello, Well I have a dilemma here. Im not too good with db desings,.. so what I have its the following:

A table Employee with the following attributes:

id:PK
eMail
name
password.

a table Turn with the following

day (The name of the week day)
id:PK
code
startingTime
endTime
maxEmployee

What is code? What is maxEmployee?



and a Join table created via (create relationship button)

TurnXEmployee
id:pk
dateOfTurn
code
idEmployee
idTurn

the code's atributes are like the oid's

Hmm.... This implies that each Turn can have multiple employees working on it and the dateOfTurn and code can be different for each Employee/Turn combination. That doesn't seem right. If two employees can be assigned to one Turn, then the date should be the same too, right?

ok so a few questions... should I put the eMail as Pk in the EOModel..

NO! Email addresses can change. Also, since you are designing a DB from scratch, NEVER use a real-world piece of information as a PK. NEVER. You are only asking for trouble later when something that everyone says will never change, changes.

or just put it as Unique in the db schema in openbase?

Yes, if it is really, truly unique. Is it possible for an Employee to have more than one address? Can an address migrate from person to person as they come and go?

the same question as for the codes.?

Same answer and questions as eMail.

in the TurnXEmployee, I will need to add the code as pk(inEOModeler) or unique(in the DB)? this is because a Employee may have multiple turns, btu at the same time multiple turns of day "monday" ie.
and the same question for eMail in Employee table?

What exactly is the code field doing for you?

Now. I asked a few days ago about the way to make this work. Overview: An Employee will log in to the system ( via eMail and password) and then a new page loads with a selectable calendar made with JS. when the user selects a day then in the right part of the page the turns for the selected day (day of the week) (mon - sun) will appear and the user can select during what time he want to work. and then submit. I read about the AjaxUpdateContainer, and the bindings it should have. but I dont know too much about JS or Ajax. (Im on the process in learning, pain in the ass), my question its.. if a WOIframe will work too? or will be easier and nicer to do it with the AjaxUpdateContainer. I tried to see the examples but could not find them...

Stop. Get the model right before you worry about what the UI is going to look like. Obviously you need to have an idea of what kind of information the user will be seeing/selecting, but don't worry about the design of the UI yet. If the data/object model is right, the UI will be obvious.

So let me review:

You have Employees that will be signing up for Turns to work, right? The thing you need to know about the Employees is just their name (worry about how they log in later). The thing you need to know about the Turns are What the starting date & time, the ending date and time.

Key questions:

1) Can more than one Employee sign up for the same Turn?
2) Are Turns the same (same start and end) from day-to-day? For each day of the week?
3) Can turns span two days?
4) Are any of these assumptions likely to change?

Dave











_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com

This email sent to [EMAIL PROTECTED]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to