0

Im trying to write a delete function for a "path" class which has data points (lat/long). It also has notes and photos along it but each of these objects have comments that also need to be deleted. Essentially everything associated with the path.

Here's my SQL attempt in the most basic

SELECT ws_paths.id as path_id, ws_path_data.path_id as data_id, 
	ws_path_notes.path_id as note_id, ws_path_photos.path_id as photo_id
	 ws_comments.object_id as comment_id

FROM ws_paths, ws_path_data, ws_path_notes, ws_path_photos, ws_comments

WHERE path_id = data_id AND
	path_id = note_id AND
	path_id = photo_id AND
	comment_id = photo_id AND
        comment_id = note_id

I feel like there could be a much better or more efficent way to do this, any advice would be greatly welcomed! Ive read everything on joins i'm just stuck on the distinctions between left, right, inner, and outter ect.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by urtrivedi
0

if you want to delete things, on path_id from the related table, so best thing is create foreign keys in all related table with cascade delete option

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.