reset password
Author Message
Rinchan7
Posts: 56
Posted 22:53 Dec 06, 2014 |

Can someone give me a hint as to how to do an item_log table correctly? I was thinking making a column for item_id, user_id, and a 3 columns for the dates (borrowed, due, returned) but I already have those 3 in my items table. Would it be redundant to have them in another table? (So that I can save the dates for all check-in/out transactions)

ggonza83
Posts: 14
Posted 23:28 Dec 06, 2014 |

The easiest way to do the item_log table (if I understand your question correctly) is to only have the item_id and your checkoutlog_id. That way when you do an sql query, you can identify the logs by their id and match it to the item_id that is required. Can you explain more in detail what you are trying to do so that I can aid you more precisely?
 

Rinchan7
Posts: 56
Posted 01:03 Dec 07, 2014 |

Thanks for the response! I was trying to see what is the best way to store all the dates that an item has been checked out/returned (so that I could get the dates that it was checked out from months back for example)

ggonza83
Posts: 14
Posted 01:57 Dec 07, 2014 |

The best way to go about this problem is to think of your tables as the values that you use in you models, so you should have a column for the same types that you have in your class. the only difference here is that instead of having a List in your item class, you have to do a collection table in your sql, like I mentioned in the earlier post. so for your checkout logs, your table should reflect that of the class. You can refer to SQL and MySQL lecture notes, slide 17 to get an understanding of how your tables should look. There is also an example table to refer to in slide 3.

calcaza
Posts: 11
Posted 02:05 Dec 07, 2014 |

Why would you have the dates in the items table? The way I did it was that on the items table which I suppose is the library or main page, I only have the fields that appear on the main page such as id, name, add. info, and available. Then for the Item log page "table" I have the student's name, CIN and those 3 dates you're talking about. Plus 2 id's, the first one is the same id as the item and the other one is a unique id for that specific student. Hope that helps, I would get more into detail but I don't know if I would be breaking any rules lol

Last edited by calcaza at 02:06 Dec 07, 2014.
Rinchan7
Posts: 56
Posted 03:02 Dec 07, 2014 |

No I got it, I just didn't think to put an available column in the items table because I thought we weren't supposed to make columns for information that can be derived from other tables. I think I got what I needed to finish thanks!