SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Validations
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aidmondo
Starting Member

Ghana
23 Posts

Posted - 05/18/2012 :  08:44:09  Show Profile  Reply with Quote
Create table Events(
EventID int Primary Key Identity,
EventName Varchar(30) not null,
StartDate datetime not null,
EndDate datetime not null,
NoOfPeople int not null
)

Create table EventType(
EventTypeID int Primary Key,
Description Varchar(50)
ChargePerPerson money
)

Create table Payments(
PaymentID int Primary Key,
EventID int Foreign Key References Events(EventID),
PaymentDate datetime not null,
PaymentAmount
)

Now the following validations are to be performed on the Payments Table.
1. Payment date should be less than or equal to the StartDate of the Event.(StartDate in the Events table)
2. PaymentAmount = ChargePerPerson * NoOfPeople (chargePerPerson in EventType table and NoOfPeople in Events table)

Can this be done in the course of creating the tables? If yes help.





aidmondo

DonAtWork
Flowing Fount of Yak Knowledge

2111 Posts

Posted - 05/18/2012 :  10:13:17  Show Profile  Reply with Quote
You can put constraints on the tables, or have calculated columns. Books Online (Help) will tell you how to do this.









How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000