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 > Basic database implementation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-12, 06:49
johnharris85 johnharris85 is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Basic database implementation

I'm pretty new to databases but am trying to implement one for persistent storage in a small python application I'm writing. The application records the loan of access cards to students. I've identified Loan, Card and Student as objects and they map to tables:

loans
- loan_id (PK),
- due_date
- return_date
- student_id (FK)
- card_id (FK)

students
- student_id (PK)
- fname
- sname

cards
- card_id (PK)
- active

Now I just need some pointing in the right direction tightening up the design so I can convert it to python/sqlalchemy code. When a student borrows a card a new loan is created (and a new student and card if they don't already exist). A card can belong to many loans (after a card is returned it can be reused) but a loan can only have one card so card to loan is a one to many relationship. Student to loan is also a one to many relationship as students can have many loans but a loan is only given to one student. Card and student don't have a relationship to each other. When I query the database I am going to have to join the tables on the FKs to get all the data I need to display in the application. Can I do multiple joins?

This is my understanding of what I need and I am ready to implement it in python code. I am really looking for someone to review the above and check I am correct and have not misunderstood anything. Is the above in 3rd Normal form? (I think it is). Do I have any problems here? Am I fine to join multiple tables?

Thanks for reading.
Reply With Quote
  #2 (permalink)  
Old 01-16-12, 07:58
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
yes, you can do multiple joins

the design looks fine to me
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Tags
beginner

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