Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Insertion and Deletion of new record

Author  Topic 

josethegeek
Starting Member

45 Posts

Posted - 2004-04-28 : 13:52:14
Hello,
I've come across a problem I have run into many times before. On past occasions I took the easy way out, and did what ever was fastest. Now that I am working on a new project that will have lots of more processing and hits I'd figure I'd try to find the best way to do it.

Currently I have 3 tables

Members
-------
Member_ID
Member_UserName
Member_Email
Member_Password

Interests
--------
Interest_ID
Interest_Name

MemberInterests
--------------
Member_ID
Interest_ID

Well, as it stands. When someone becomes a member, they have the option of specifying their interests, so other members with the same interests can find them. We currently show them the list of interest with a check box next to them. The first time they select their interests all I do is add them to the memberinterests table. But when they go and update(add/delete) interests, I currently delete any interests they have in the table and add the once they've selected. I'm sure there is a better way. I hate having to delete the interest they have in the MemberInterest table and reinsert them again when they just added or deleted one record from/to their interest list.

Thanks,
Jose

X002548
Not Just a Number

15586 Posts

Posted - 2004-04-28 : 13:57:24
Exactly...How do you know they've deleted an interest...

You need to do the delete with both ids....

Member and interest, not just member

Man, are there really that many dating sites out there?

Get a hobby....



Brett

8-)
Go to Top of Page

josethegeek
Starting Member

45 Posts

Posted - 2004-04-28 : 14:46:38
quote:
Originally posted by X002548

Exactly...How do you know they've deleted an interest...

You need to do the delete with both ids....

Member and interest, not just member

Man, are there really that many dating sites out there?

Get a hobby....



Brett

8-)



Basically they have their own interests page where we list all the interests that we have. If they have previously selected a couple of interests we automatically check the box. If they uncheck a box that was check, or check a box that was not checked. The we either add or delete from the MemberInterests table. I currently delete any Interests for that member and repopulate the table with the members interests.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-04-28 : 15:24:52
Is it event driven? Yes?

Do you know what control is being modified?

Yes?

DELETE FROM MemeberInterest WHERE MemberId = @MID AND InterestID = @IID

OR INSERT INTO MemeberInterest WHERE MemberId = @MID AND InterestID = @IID



Brett

8-)
Go to Top of Page

cas_o
Posting Yak Master

154 Posts

Posted - 2004-04-28 : 16:17:17
I don't like deletes either, I tend to have a dlt_flg bit column in most tables and set it to 1 for deleted.

You need to do it from beginning of new database, introducing it later is a nightmare coz you have to add the column to every single sp and statement in the whole app and database.

But you've got history then, and undo capability. And you can easily delete from tbl where dlt_flg=1 later and under controlled circumstances.



;-]
Go to Top of Page

josethegeek
Starting Member

45 Posts

Posted - 2004-04-28 : 16:55:09
quote:
Originally posted by cas_o

I don't like deletes either, I tend to have a dlt_flg bit column in most tables and set it to 1 for deleted.

You need to do it from beginning of new database, introducing it later is a nightmare coz you have to add the column to every single sp and statement in the whole app and database.

But you've got history then, and undo capability. And you can easily delete from tbl where dlt_flg=1 later and under controlled circumstances.



;-]



Thanks
Go to Top of Page

josethegeek
Starting Member

45 Posts

Posted - 2004-04-28 : 16:56:03
quote:
Originally posted by X002548

Is it event driven? Yes?

Do you know what control is being modified?

Yes?

DELETE FROM MemeberInterest WHERE MemberId = @MID AND InterestID = @IID

OR INSERT INTO MemeberInterest WHERE MemberId = @MID AND InterestID = @IID



Brett

8-)



Thanks
Go to Top of Page

cas_o
Posting Yak Master

154 Posts

Posted - 2004-04-28 : 17:38:32
What a nice guy.

;-]
Go to Top of Page
   

- Advertisement -