I’m looking to develop a MySQL database. The main unique piece of information for this database will be a MAC address (eg. AA:BB:CC:DD:EE:FF). For each MAC address record, there will then be a number of subrecords which will record when these MAC addresses were recorded. So this field will be a subrecord for the MAC address if you like and will contain the following:-
- Reference number for device that detected the MAC address
- Date and Time
- Longitude
- Latitude
This will be passive data that is just continually connected from a network. Nonetheless, I’d also like to have an active table / list whereby I can specify a MAC address and if it is detected, a record is logged with the same information above.
I’m wondering what’s the best way to structure this information? I assume I would have one main table containing the MAC addresses and then a foreign key linking it to another table containing the ref number, date and time, long and lat? How is best to structure passively collating the information though and actively collating the information.
With the data collated passively, I may want to query it at some stage however with the active list (MAC addresses to look out), I want to set an email alert when these are detected and so I don’t know whether to store these separately.
Ideally I’d like to have all the data in one table for passive or active data and so I’m just wondering if I can add a further column to the main table containing the MAC address marking it as ‘active’ so that for any detections for this MAC, I can then generate code to create an email?
I hope this makes sense
I think you are on the right track. Have a primary table with the MAC addresses and an ID, then the other table could track the activity of the MAC address (ID, MAC_ID, REF_NUM, DateTime, LONG, LAT). I think having a flag in the MAC address table is a good idea to key on or you could have a separate table containing the MAC_ID (or MAC Addresses) and use it as a lookup table. You might need to create a trigger so that if a MAC Address is sent that is in the ‘watch’ table, it kicks of the insert into the ‘Active’ table which sounds like it would be a duplicate of the activity table with the REF_NUM, etc.
Another option would be to combine the tables and just have a flag in the activity table that is checked if the MAC Address is found in the lookup table or if that row was inserted via the trigger. Just thinking out loud.
Here’s an example of the table structures with example data: