0

Hi,
I have A DB look like this :
events(type,event_from,event_to,description,owner,perm,repetition)
and
repetition(repetitionid,description)
repetitionid = repetition
and repetition look like that :
0;"None"
1;"Every day"
2;"Every week"
3;"Every month"
4;"Every Year"

my question is by giving owner how can i found all hes events ?

3
Contributors
4
Replies
7
Views
7 Years
Discussion Span
Last Post by tesuji
0

Hi,

assuming your data model is correct an owner's event list can be created by

select * from event WHERE owner = 'yourOwner';

* should be avoided and replaced by the list of row names you actually need,

e.g.

select event_from, event_to, description from event WHERE owner = 'yourOwner';

Edited by tesuji: n/a

0

Do you mean 'find all his events forever' or 'find all his events today' or something else?

You might want to think again about whether this is the best way to specify possible repeating events.

You might want to allow the user to specify the count of units to repeat: Every 3days or every 5 weeks or whatever.

0

Hi,

assuming your data model is correct an owner's event list can be created by

select * from event WHERE owner = 'yourOwner';

* should be avoided and replaced by the list of row names you actually need,

e.g.

select event_from, event_to, description from event WHERE owner = 'yourOwner';

yes but in this case I will recive only one event ,

I wont for example if i have event
(1,1/1/2010 10:00:00,1/1/2010 11:00:00,abc,owner,1,3)
BECAUSE repetition =3
this event repet every month
I wont output like this:
1/1/2010 10:00:00 1/1/2010 11:00:00 owner
1/2/2010 10:00:00 1/2/2010 11:00:00 owner
1/3/2010 10:00:00 1/3/2010 11:00:00 owner
1/4/2010 10:00:00 1/4/2010 11:00:00 owner
1/5/2010 10:00:00 1/5/2010 11:00:00 owner

0

Yes, I was afraid of that. Based on your data model the result you endeavour to cannot be achieved by way of simple select statement (there is no loop statement for select to-day, yet there are case and if). There are two solutions:

1. Do it in any programming language, e.g. php, java, c, c++ ... using a proper sql api

or

2. Improve your data model (try to archieve 3NF)
(repetition column is a nice thing which is responsible for that table events even didn't meet 1NF)

-- tesu

Edited by tesuji: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.