gnuvince
gnuvince

Reputation: 2387

Which data model to use to represent nested categories in a small SQL database?

I am writing a small web site for work where employees can consult video capsules on how to use the different programs that we use. I was asked to organize the videos by categories and the categories need to be arbitrarily nested.

I've been looking into two ways to model this: nested sets and adjacency lists. They both seem to have their ups and downs, and I was wondering if somebody could help me choose the model that would best fit my usage scenario.

Thank you for you help.

Upvotes: 2

Views: 401

Answers (2)

Randy
Randy

Reputation: 16677

category
--------
category_id
name

category_nesting
----------------
parent_category_id
child_category_id

video
-------
video_id
more_stuff

video_category
--------------
video_id
category_id

Upvotes: 0

Nicholas Carey
Nicholas Carey

Reputation: 74277

If it's a small lightly used database that's unlikely to see a lot of change....I wouldn't sweat the issue. Don't spend a lot of time thinking on it: just do it in the simplest, most straightforward, easiest to understand/implement manner.

Git'er done, as they say.

Upvotes: 1

Related Questions