I have a SQLite DB which stores log information for me. Sometimes some of the values could be editable, sometimes others are not editable.
To avoid having for each information two columns, I decided to create an extra table with two values to which the other table refers.
e.g.
LogDetail
- Id
- Value
- Editable
LogTable
- Id
- FK_Timestamp
- FK_User
- FK_Titel
- FK_Description
e.g. LogTable:
- 1 1 2 3 4
LogDetail:
- 1 "Timestamp1" True
- 2 "User1" False
- 3 "Titel1" True
- 4 "Description1" True
Each of the FK_ entries is a foreign key which referred to LogDetail. Now I want to combine these informations to one row. There are many possibilities to achieve this. I tried this:
SELECT TimestampT.Value,
TimestampT.Editable,
UserT.Value,
UserT.Editable,
TitelT.Value,
TitelT.Editable,
DescrT.Value,
DescrT.Editable
FROM Log,
LogDetail AS TimestampT,
LogDetail AS UserT,
LogDetail AS TitelT,
LogDetail AS DescrT
WHERE Log.FK_Timestamp == TimestampT.Id
AND Log.FK_User == UserT.Id
AND Log.FK_Titel == TitelT.Id
AND Log.FK_Descr == DescrT.Id
Is it better to use multiple WHERE conditions or JOINS or something other? What is the most readable, what is the fastest in SQLite?
And if I get more columns, is there an easier solution for this problem then always add 4 lines for each columns?