Results 1 to 8 of 8
  1. #1
    luca is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Location
    Queens, NY
    Posts
    6

    tables design

    Hello everybody!
    I am almost as new to Access as to this forum...
    I'm trying to create a database to keep track of some equipment. This is the problem I have (for not thinking yet in Access):
    -I have a table with two fields: Model (text) and SerialNo (text);
    -For some models I need to store more info - say Time Counter (Integer), Last Error (Integer), etc.
    -How do I do this? It looks like a common situation, but I'm very confused at this point...
    Not only I have a nonhomogenous table (with different number of fields for different records), but the problem propagates when I create the form: when I select (in a lookup) a certain model I need to be able to be shown and fill in the info according to that model.
    An easy solution would be to just create the table with all the extra fields and leave them empty for models that do not have that info (90% of them). Is there a better solution?


    Thanks for any input!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Think of those extra fields as records in another table rather than extra fields in the current table. Your current table should have an AutoNumber as a PrimaryKey field and then you put this number in the other table as a ForeignKey field (LongInteger) creating the 1:m relationship. You can now have as many "other" pieces of data for each SerialNumber as you want and use a Form/SubForm to View/Edit/Add to the "Other" table.

  3. #3
    luca is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Location
    Queens, NY
    Posts
    6
    Thank you, RG for your help. I'm still confused, though. The situation you describe looks like a Order/Order details case, where for each order there is a variable number of records stored in the 'details' table. You might be right, but I'm not sure we talking about the same thing. My situation is this:
    Let say the table is tblObjects, with the fields Model and Serial. The models can be A, B, C, D, E, F. Now, if Model=E or Model=F, I have 2 extra fields to add to tblObjects - ex. Error, Time. These 2 fields are specific to those models (E and F). It looks like I need 2 tables: one for models A,B,C,D with fields Model and Serial and one table for models E, F with fields Model, Serial, Error, Time. The problem is that tblObjects is in a 1:m relationship with another table; if I have two tables instead of one, it changes everything...
    So my problem is having variable number of fields based on the content of a specific field (Model) and not a variable number of records.
    What am I missing here?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Well now I'm completely confused. You can not have a variable number of fields in a table. You can however ignore some fields depending on the value of other fields in the table.

  5. #5
    luca is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Location
    Queens, NY
    Posts
    6
    Thank you, RG for getting back to me! Confusion is contagious! I'm sure if you'd have had to design the (simple) database I'm working on for over 3 months now (and more than 4 Access 2007 books, including 'The Bible'), you'd be done long ago, without any confusion.
    I'm trying to put in order some information I collect from repairing some electronics equipment, not for the posterity, but to make it useful to me.
    The question is: what do you do when the objects in your database (or table) have many features (fields) in common, but differ in some? Like, you have a DB of vehicles, some cars, some SUV's, some trucks. They all share some fields - VIN, price, man. year, etc - but differ in others: cars - number of seats, doors, etc, SUV- traction, max. last, tracks-axles, etc. They do belong together (in a table) and they don't.
    How do DB designers deal with this? It has to be a very common situation, with a simple (not to me) answer. Creating different tables with different fields and then putting them together with a query? And base the form on that query? Always confused!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    If you include ForeignKeys in your tables then you can put everything back together in a query as if it is in one table. That is the power and beauty of a relational database and queries.

  7. #7
    luca is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2009
    Location
    Queens, NY
    Posts
    6
    Thank you, RG.
    I've come to realize that putting the extra info (fields) in a separate table and linking this as a child ('many' side) to the main table, allows me to attach the extra info needed to the 'special' cases (records) that need it, but without wasting any space, because the 'parent' can have any number of children, including zero! Problem solved! Thanks again!

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    That's great! Are you ready to use the Solved thread tool yet?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Relationship Design
    By krymer in forum Database Design
    Replies: 3
    Last Post: 11-28-2008, 09:09 PM
  2. design using relationship...
    By dsnyder in forum Database Design
    Replies: 2
    Last Post: 10-21-2008, 12:00 PM
  3. newbie needs design help
    By ashiers in forum Database Design
    Replies: 0
    Last Post: 09-13-2008, 07:05 PM
  4. Joining tables two tables and another table that is not
    By DevintheDude in forum Database Design
    Replies: 0
    Last Post: 09-12-2007, 08:56 AM
  5. Design help
    By marix in forum Database Design
    Replies: 1
    Last Post: 04-18-2007, 07:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums