Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 Tags
Subject: RE: JOIN to 2 fields?
Thread ID: 289027 Message ID: 289064 # Views: 31 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Tuesday, December 28, 2010 8:18:38 AM         
   


> >
> >
> > If you ask me, I would never do it that way. :-)
> >
> > What will happen if both stud_id and empl_id have values? If you will say that only one will have a value at a time that when either empl_id or stud_id have a value, the other one will have zero; then I will say that that is a waste of space consumed by that unnecessary extra field. I would rather make a single field for the borrower like this:
>
>
> Hello Jun
> I forgot to mention that the students and employees tables already exist, and they are necessary for my school app. So creating a borrower table is not an option.
> You're right: only 1 field stud_id OR empl_id will have a value, the other field gets then a zero. A book is either borrowed by an employee or a student.
> The library is just an additional module in the school app.
> How would you do it then?
>
>
>
>

>
> Regards
> Samir


How will I do it? I will modify the tables. :-U

Well that is how I think I will do it. I have done things like that in the past when I see that I err in my design, I made adjustments to correct it. I always try to make the tables smaller as I can get them and one way is by removing unnecessary fields or replacing character fields with an integer fk. I have done that in my previous BBGSoft project and that is how I think I learned better, yeah it is hard but in the end I am more satisfied.

Anyway, combining student and employee records can be done easily via an SQL SELECT. I don't know though in your codes how much it will be affected by said modification.

If the notion of adjusting your tables does not really appeal to you, then I guess what you have shown is enough. Or what Ony Too has shown (I never tested his). But pardon me, like I said, it is a little bit "buggy" that "if" both employee and student fields have numbers, then only one will be gathered by your SQL SELECT.

http://www.junblogs.com/
http://weblogs.foxite.com/sandstorm36/default.aspx
http://www.coderisland.com/forum/viewforum.php?f=10

ENTIRE THREAD

JOIN to 2 fields? Posted by Samir H. @ 12/28/2010 3:29:25 AM
RE: JOIN to 2 fields? Posted by Jun Tangunan @ 12/28/2010 5:40:29 AM
RE: JOIN to 2 fields? Posted by Samir H. @ 12/28/2010 8:00:42 AM
RE: JOIN to 2 fields? Posted by Jun Tangunan @ 12/28/2010 8:18:38 AM
RE: JOIN to 2 fields? Posted by Ony Too @ 12/28/2010 6:06:41 AM
RE: JOIN to 2 fields? Posted by Samir H. @ 12/28/2010 8:51:19 AM