If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > database concept newbie question.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-12, 02:33
jpenguin jpenguin is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
database concept newbie question.

Hi everyone.

As the title says. I just recently started learning python UI and postgresql. This is kinda my personal learning project I'm trying to figure out and would appreciate any suggestions.

The idea is I'm trying to record an "item"
an item can only be under 1 shot
a shot can only be under 1 episode
an episode can only be under 1 project.

So the structure is similar to windows directory.

Project --> Episode --> Shot --> Item

--> are all one-to-many I guess?

The way I want the UI to work is like this

Show list of projects.
Click a project, show lists of episodes next to it.
Click an episode, show lists of shots next to it.

The user can choose to list "items" after selecting only the project. Selecting episodes and shots are optional which will scope down the list even further.

Now to the database. I think there's 2 main idea I can use. Which would be better for this? What are the advantages/disadvantages of the 2?
Attached Thumbnails
database concept newbie question.-data-table.png  
Reply With Quote
  #2 (permalink)  
Old 01-05-12, 04:51
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by jpenguin View Post
--> are all one-to-many I guess?
yes

the first of the two diagrams is the correct one
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-05-12, 05:37
jpenguin jpenguin is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
Thanks r937

About naming, is it better to match the names I'm creating foreign keys for? Right now I have

project.id = episode.project_id

should it be like this instead? Or doesn't matter?

project.project_id = episode.project_id
Reply With Quote
  #4 (permalink)  
Old 01-05-12, 05:40
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by jpenguin View Post
Right now I have

project.id = episode.project_id
that's the way i do it

why? because it's obvious which one is the primary key and which one is the foreign key

if they're both named the same, you can't tell
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On