14 ms·
I took a course in prolog, really seemed to help get my mind in the right place. Basically, instead of thinking in terms of how to get to the result, think ins
by beatgammit 8y ago
I took a course in prolog, really seemed to help get my mind in the right place.
Basically, instead of thinking in terms of how to get to the result, think instead of the result and figure out how to get there. For example, let's say I need to get a mapping of students to their classes. One way would be to get the students, then loop through that to get classes for each one. Another way to do it would be to ask the database to combine those sets of data for us instead and return the result (join students and class tables on the student ID).
Basically, find the data you want from each table, tell the database about the relationship between them (join on <field>), and set up your constraints. I guess you could think about the query as a function, and you're just writing the unit tests for it (when I call X with parameters Y, I expect Z).
- arkh 8y ago> I took a course in prolog, really seemed to help get my mind in the right place. I have the reverse problem: every time I motivate myself to learn Prolog I feel like I could just input the constraints in a db and use SQL to get my results.