SQL Server 2008 Express

I am designing a database which would have a table (containing contact details like Contactid name Number and address)

I want to add notes every time when a contact visits my office, with date and time.

So I created another table visit (Visitid, Visit date, Notes, Contactsid)

But I am unable to create a relationship as one contact can have multiple notes.

What I want is?

When I select a contact in the UI then it shows me the visit history and option to enter new visit notes

Thnx

Answers


I don't quite follow - you should be able to definitely establish a foreign key relationship between Visit and Contact like this:

ALTER TABLE dbo.Visit
  ADD CONSTRAINT FK_Visit_Contact
  FOREIGN KEY(ContactID) REFERENCES dbo.Contact(ContactID)

This links each visit to exactly one contact - but each contact can have any number of visits, of course.

To get all visit for a given contact, when you select it in your UI, you'd use something like:

SELECT VisitID, VisitDate, Notes
FROM dbo.Visit
WHERE ContactID = @ContactID

and then you'd have to set the @ContactID parameter to the proper value (the ID of the contact chosen in your UI) before executing this SELECT.


Need Your Help

Diff: ignoring lines with just tabs

regex diff

I'm trying to diff files, and determine if they are the same, but ignoring ALL whitespace. When using diff, the -b tells diff to ignore whitespace on a given line. The -B option tells it to ignor...

Javascript does not execute with ClientScriptManager in ASP.Net

javascript asp.net

I have a composite control with some buttons. This is the code of a button.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.