-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database schema without foreign keys may introduce inconsistent data #70
Comments
@sseppi FYI |
I tried on a old dump of the databese the following query: select * from info
where id not in (
select id from beacon_data
) There I received exactly the same result (same ids) and additionally the records of: select * from info
where id not in (
select id from order_data
)
order by id; The resulting info record have the following values as name:
I investigated a bit and found out, that before we eliminated the google spreadsheet, every time a new line was found in the sheet (line with empty id) an info record was created with an id that was generated randomly. Random iBeacon values and EddystoneBeacon values were generated too. After the creation of the info record, an Is it possible that it was used to fetch all beacons from the system that are planned (or requested) but not yet ordered? To make a bulk order? Based on this analysis, it is very plausible that select *
from info
where id not in (select id from beacon_data) Anyway, since the last recent changes, the |
@sseppi and I had a discussion, and we found out that this table has no longer interesting information for us. We should replace it with the following columns: "order_id" (<-- PK) and "created_at", and then put a foreign key "order_id" from the table Since we eliminated the spreadsheet import, we should also remove the remainders inside the db... |
What should contain the replaced order_data columns? Should the order_id be the order_id of kontakt.io? In this case the content of the table would be completely changed. At the moment, as I analysed it, order_symbol is the "ID" of an order, but this is just an internally generated identifier. "created_at" of the current table is the time stamp when the record was created. So I think if you want to memorize the orders from kontakt.io, then it is a new functionality and we have to recover the data of the existing beacons. |
Yes, that would be a complete new approach, that is, a reuse of that table. If we have time to do it, would be nice... otherwise, if it is too late before our meeting, we could move this into a future development cycle. |
Hi Peter, I agree it is a nice activity, i like foreign key and database constraints in general, but I think is too far from the list of activity we have to do in this development cycle and moreover too short time to make an estimations of the required time. |
@davidebz That is good... I move it to a "future" milestone then... eventually I will do it, if time allows |
At the moment we have some orphans inside "order_data", which do not have a beacon assigned inside "beacon_data" (production environment). And on the testing environment we have test beacons that do not have any order_data assigned. This happened because there are no constraints of the database tables with foreign keys. We should add them to avoid such problems and to understand how tables are connected.
The text was updated successfully, but these errors were encountered: