New answers tagged

0

TL;DR -- explain how db's work Long version: You can't show that removing a FK can not cause corruption, because that is not actually true -- theoretically it could. What you can show, is that it doesn't cause corruption and explain why the chance of it causing corruption is more theoretical than actual. I would start with why the chance of it actually ...


3

As you simply cannot create a foreign key against an array column, you should store the experiments in the proper relational way. This is what you mention as a junction table. It is a table like the following: CREATE TABLE experiments ( method_id integer REFERENCES methods (method_id), method_class_id integer REFERENCES method_class ...


2

In Postgres 9.5, the most elegant, simple, safe and fast solution is the new UPSERT implementation: INSERT INTO device (device_id) VALUES (1234567) ON CONFLICT (device_id) DO NOTHING; -- now we have either inserted the device or it was there already INSERT INTO data (device_id, data) VALUES (1234567, 'some data); Obviously, there must be a some kind of ...


0

I always try to register devices first and then only they can send data.But in your case ,you can try some thing like below if exists(select 1 from devices where deviceid=@deviceid) insert into datatable else insert into devicestable insert into datatable Exists is always faster,but you may to have see if the column which we check for existence is ...


-2

In my opinion Select exists should be good in terms of performance. As select is faster than insert in terms of performance.Select only reads data and return the result, The insert query must read that data, insert in the table, then it check for primary key and found guilty of duplicate, then it revert the changes and raise an error.



Top 50 recent answers are included