Re: Database code or application code.
- From: "sloan" <sloan@xxxxxxxxx>
- Date: Tue, 24 Feb 2009 14:19:48 -0500
To me, some of these point to unique constraints.
Don't get me wrong I prefer business rule validation in the business layer,
not the database.
But these look like UNIQUE CONSTRAINTS.
You have to ask yourself, What makes an EVENT unique? The name? The name
and date?
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[Event]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
DROP TABLE [dbo].[Event]
END
GO
CREATE TABLE [dbo].[Event] (
[EventUUID] [uniqueidentifier] not null default NEWSEQUENTIALID() ,
EventName varchar(64) not null ,
EventDescription varchar(128) not null
)
GO
ALTER TABLE [dbo].[Event]
ADD CONSTRAINT PK_Event_EventUUID
PRIMARY KEY CLUSTERED (EventUUID)
GO
ALTER TABLE dbo.Event
ADD CONSTRAINT Event_EventName_UNIQUE UNIQUE (EventName)
GO
As far as the timeslots, you might look a "time lookup table" where you put
in 15 minute increments or something.
Time rules are especially difficult, especially "prevent overlapping".
I'd seek some more advice in this area.......
"Andy B." <a_borka@xxxxxxxxxxxxx> wrote in message
news:eSzuuzqlJHA.5920@xxxxxxxxxxxxxxxxxxxxxxx
I have an object that is quite complex. It is called Event. Here are some
of the rules I need to place.
1. An event can't be duplicated.
2. When adding new events to the system (sql server 2008) and a duplicate
is found, ask the user if they want to replace the current one with the
new one or just cancel out of the add process.
3. Events can't be scheduled on top of each other. The start/end dates and
times for the new event being added can't be in the range of existing
events. For example, If an event is scheduled for 3/1/2009 7:00pm -
3/1/2009 8:00pm, the new event can't start/end on that day between 7-8pm.
For this rule to work, the database would have to be scanned for all
available/not available times and then enforce the rule.
"Lee Atkinson" <lee@xxxxxxxxxxxxx> wrote in message
news:C5C9DD10.3CBA%lee@xxxxxxxxxxxxxxxx
What kind of rules are you talking about?
On 24/02/2009 16:59, in article u2IcPFqlJHA.4396@xxxxxxxxxxxxxxxxxxxx,
"Andy
B." <a_borka@xxxxxxxxxxxxx> wrote:
I have some business rules that apply to some data in a database. I'm
trying
to figure out if it should be put in the database or the application.
Where
should I start?
.
- References:
- Database code or application code.
- From: Andy B.
- Re: Database code or application code.
- From: Lee Atkinson
- Re: Database code or application code.
- From: Andy B.
- Database code or application code.
- Prev by Date: Re: Entity framework or just plain old SqlDataReader?
- Next by Date: Re: Drop Downs tool tip doesn't work
- Previous by thread: Re: Database code or application code.
- Next by thread: Re: Database code or application code.
- Index(es):
Relevant Pages
|