|
-
Dec 8th, 2016, 03:14 PM
#1
[RESOLVED] table design
Hey all, I need a bit of help designing a couple of tables to make sure I have what I need at the end of time.
I have a table (tbl1) with a primary key (id) and a number of fields (30+) . Many of these fields are static fields that I can get with a simple select statement, but about 10 of these fields need different values based on another variable (named OP).
For example if OP = "X" then when I fetch the data for I might get something like this...
v1,v2,v3,ex1,ex2,ex3
However, if OP = "Y" I might get something like this...
v1,v2,v3,whY1,whY2,whY3
Now I suppose I could just create unique rows for everything, but that would yield a large amount of redundant data.
What I am considering is to have 2 tables. The first table would have the 30+ fields and the other would have a foreign key that points back to a particular row in the first table and another field that holds the OP value. That seems like a reasonable way to do this right?
If so, I am quite stuck on how the select statement would look.
It doesn't seem that a join would be used for this, but I am really not sure.
Can someone please let me know if my approach is sound and if so, show me how to construct the select statement for this?
thanks
kevin
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|