Before inserting a record that depends on another... - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-10-2009, 03:56 AM   #1 (permalink)
Junior Member
 
Join Date: Jan 2009
Posts: 1
Default Before inserting a record that depends on another...

For example, I have 2 tables: groups & users__groups,
the 2nd one depends on the 1st (users__groups.`group_id` on groups.`id`).


The question is, which approach to take to keep the users__groups table clean:

1) When user joins a group, issue a conditional insert that checks whether the group the user wants to join exists. (This approach is to prevent from forgers to insert duplicate data.)

2) Inserts are with no condition (= faster) but then arises the need to delete junk records (inserted by forgers) from time to time. (Most people are legit users, so I don't think there would be too much junk records.)

And regardless of which approach taken: have a unique index in the users__groups table (in my case it spans 2 columns: `user_id` & `group_id`), this approach narrows possible (by forgers) junk records to one per combination of user & group, as the `group_id` (that can be forged) is not checked.
It also speeds up SELECTs & JOINs.
But, slows inserts (users join groups very frequently).


The BIG question is: performance-wise, is it better to have ALL my INSERTs with conditions to check that they are legit OR from time to time issue DELETEs to delete junk records?


Thanks.

Last edited by Cheburgena; 01-10-2009 at 04:09 AM.
Cheburgena is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 05:35 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting