also with postgres you can stick arrays in your data models (dont know if thats a good thing)
mcspud
Codd would cry
jessamynsmith joined the channel
schinckel
I use arrays when it makes sense to.
Bouris has quit
If there will never be more than a known number of choices, it isn't such a bad idea.
For instance: to store something that may refer to between 0-7 weekdays, I store the ISO weekday values as an array.
thmcmahon joined the channel
mcspud
I used to make that assumption about gender, but apparently I was wrong :)
FunkyBob
Remember: "It's the word of Codd, not the word of God."
mcspud
#controversy
schinckel
Anything that needs to refer to a different set of possibly changeable data can't be stored as an array: at least, not without breaking referential integrity.
helical has quit
mcspud
Technically anything that is stored as an array, mutable or not, breaks 4NF
But as FunkyBob said...
schinckel
Indeed: but practicality beats purity.
mcspud
Agreed
thmcmahon
hi all, i want to have a model with a field that is based on the primary key, which is just the primary key prepended by a bit of text. i.e. PREFIX99 for the 99th entry in the database. I've tried to override the save method, but the primary key doesn't exist yet, so I think it needs to happen post save but I'm not sure how to do it. Grateful for any assistance.
UnknownSoldier has quit
Koterpillar
thmcmahon: make it a property
FunkyBob
mcspud: then again, technically datetime fields break 1nf (or is it 2?)
magnusgraviti joined the channel
mcspud
thmcmahon - define it as a property on the model so it is computed when it is inspected
thmcmahon
Koterpillar mcspud thanks guys, wasn't sure what it was called, I'll have a look at properties
So even "First Name" can technically break it if there are 2 people named "Peter"
Koterpillar
how is that different from an integer field?
mcspud
But again, practicality
Koterpillar
ah, yes, ok, that one
mcspud
Koterpillar - its not
helical joined the channel
samsagaz_ joined the channel
In practice any reasonable finite set of choices that can be changed over time should be split into their own table, but `reasonable` is very subjective
Koterpillar
hmm
Technodrome has quit
the "set of choices" bit is one I'll pick on
schinckel
Also, if you are going to be _ordering_ by one of these "choices" (i.e., a timestamp, or even a name), then putting that value into a seperate table is probably going to be counter-productive.
Yeah, it's not strictly a limited set of choices.
Koterpillar
time is continuous, therefore the set is infinite
schinckel
I mean, there are an unlimited number of ... yeah, that.
mcspud
Koterpillar - any DB system will have the deepest level of granularity it can go do though
so at 1ms increments, in the purest sense of it you should do that via FK relationships to a "Time" table
Koterpillar
I feel like building a DB with unbounded precision floats, that has AWS keys, automatically orders itself new hardware and blocks calls until it's fulfilled
in fact, scratch that
Guest63578 is now known as rgenito
mcspud
dont do that
username_ has quit
Koterpillar
let's fork pg to report virtual tables like "datetimes", "floats" and such, and making float fields seem like FKs to that table
SELECT * FROM floats; will still work, obviously
schinckel
hahaha
mcspud
We are going down a deep, dark hole here
Koterpillar - I feel like Joe Celko has written something about this before :P
Koterpillar
note that this hole is bounded
thmcmahon has quit
schinckel
happy to watch, not getting involved in this one, as fun as it sounds.
mcspud
He probably has a valid usecase for it
haha
FunkyBob hands out the popcorn
schinckel munch
helical has quit
Off the top of anyones head, does anyone know if, when calculating an income stream for an income/expense report to what period you assume it is valid? I'm guessing you annualise it, so 100/month income from child support becomes $1200 etc
helical joined the channel
Technodrome joined the channel
SecondForm_Glenn joined the channel
Combined2857 has quit
EyePulp joined the channel
qengho
Hi hi hi. I am having trouble with the model interface. Imagine three model tables that together represent an Exam, some Exam Questions, and a student's Exam Question Answer to the exam questions. I see how I can start with exam questions answers and follow related links to Exam and Exam Questions. I want to use the database state to know what exam questions are not yet answered. That is I want to
construct a to-do list from db state. So, Exam has a incoming fk from Questions. A Question has incoming fk from Answer. (There are other things on answers that make it unique to a student.) I want to subtract Answers from Questions to know what's unanswered. How can I do this nicely with django models?