I need to create a vehicle tracking database. There are several vehicles that send data, consisting of around 20 parameters, to my database.

The parameters of a vehicle include the constants vehicle number and hardware id, along with a variety of variable items.

I will have a table in this database containing the login credentials of the users and I would like to create a link between the two tables with the vehicle number as primary key in the login table and with the vehicle number in table containing parameters.

Since the vehicle number column is redundant I cannot have it as the primary key.

I would like to know:

  1. What way can I achieve the link between tables
  2. Is there a good way so that I dont store this vehicle number and hardware id so many times.
  3. Should I be storing each vehicle's data in separate table rather than all in one table?

This is the first time I am designing a database. I have only been a programmer to date.

  • 1
    this was cross-posted on SO stackoverflow.com/questions/12457367/…
    – Taryn
    Commented Sep 17, 2012 at 10:33
  • Could you provide an English description of the tables and what the link represents?
    – NoChance
    Commented Sep 17, 2012 at 12:52
  • @bluefeet The SO post has been closed because of the Xpost.
    – JNK
    Commented Sep 17, 2012 at 14:31

2 Answers 2


I expect this model to be a bit more complicated than two tables. If the vehicle tracking provides you with two IDs, then they may probably be foreign keys to some specification. Also, it is entirely possible that different vehicles will have the same hardware, and the other way around, different hardwares will have the same vehicle. In that case, you need to normalize it by placing in different tables.

My proposition is based on the following model:

Vehicle system model


Thanks to @DamirSudarevic I've made some updates in the model.

  • 1
    Tracking must point to Vehicles_Hardware FK {vehicle_number, hardware_id}. The way it is now, it allows for any combination of vehicle_number, hardware_id even if they are not paired together. Commented Sep 18, 2012 at 12:00
  • 1
    Also User_Cars and Vehicles_Hardware, both FKs should be part of a PK, -- the way it is now, both tables allow duplicate entries. Commented Sep 18, 2012 at 12:17
  • In both comments, you are right. I'm just unable to correct the answer at the moment, I'll do it later on...
    – WojtusJ
    Commented Sep 19, 2012 at 7:56
  1. You create the link between the tables with a UserVehicles table containing foreign keys to the Vehicles and Users tables.

  2. The HardwareId would never be stored more than once. The VehicleNumber would be stored multiple times only when necessary to show the relationship.

  3. No, each vehicles data should be in the same table.

Your design will probably look something like this:




Re-reading your question I'm wondering if by "vehicles keep sending data" you are tracking some sort of values that are fluctuating rather than attributes of the vehicle. If this is the case you may need something like this (substituting each stat with a specific name and well defined type):

 Stat 1
 Stat 2
 Stat 3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.