OCAJP 7
Stuie Clarky wrote:In my opinion you are probably worth getting the database up and running now...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:System.currentTimeMillis() + cyclic or random sequence (or both) that fits in a long.
1. Check whether the word already exists in the database (preferably run a spell check as well)
2. If the the word doesn't exist, add it to the database and create a new entry in the linking table
3. If the word exists, create a new entry in the linking table to link it with the review
margaret gillon wrote:
1. Check whether the word already exists in the database (preferably run a spell check as well)
2. If the the word doesn't exist, add it to the database and create a new entry in the linking table
3. If the word exists, create a new entry in the linking table to link it with the review
To me it seems this process would be better is a database stored procedure / function. If your process is done from the program then
1. has to do a select, if there is no return then
2. has to do an insert , then another select has to be done to get the new id from the table
3. then does another insert into the linking table with the new word id
so you are calling the server 4 times from the program
I admit that I like databases and try to store logic in them so there is consistency when the database is updated from multiple applications. I work in a place where multiple IT departments use different programming languages to access company data. I have seen the chaos that results when the business rules are in the programs, isolated from the data.
A question, how are you handling plurals in your word table? If I were searching for "word" I would hope that "words" would be a related search, and what about plurals that have a spelling change ? elf = elves , tooth = teeth
What is wrong with populating the database with all plurals. It might be more work initially, but the programming afterwards may be easier. I have had such a database since I was about three years old, including the rule about adding ‑s. That database is installed somewhere in my head.Paul Mrozik wrote: . . .
A good point on the plurals - I hadn't even considered it. . . . but with the irregular words I see no other way than to just populate the database with the irregular plurals.
Jeff Verdegan wrote:Or just use a monotonically increasing long. You'd have to use a file (or java.util.Preferences) to store the value between runs of your app.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Paul Mrozik wrote:A good point on the plurals - I hadn't even considered it. With most words I suppose that it wouldn't be a problem because we can just add s or es, but with the irregular words I see no other way than to just populate the database with the irregular plurals.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:
What is wrong with populating the database with all plurals. It might be more work initially, but the programming afterwards may be easier. I have had such a database since I was about three years old, including the rule about adding ‑s. That database is installed somewhere in my head.Paul Mrozik wrote: . . .
A good point on the plurals - I hadn't even considered it. . . . but with the irregular words I see no other way than to just populate the database with the irregular plurals.
Winston Gutkowski wrote:
Paul Mrozik wrote:A good point on the plurals - I hadn't even considered it. With most words I suppose that it wouldn't be a problem because we can just add s or es, but with the irregular words I see no other way than to just populate the database with the irregular plurals.
And this is why, like Margaret, I think:
(a) You need a database. (b) A lot of your "relationship" logic needs to be in the database; I'd say mostly in the form of constraints. Procedures are OK for really esoteric stuff, but I have to admit that I much prefer triggers (assuming your DB supports them). That way, your app simply communicates via standard SQL.
The business of plurals is a tricky one, because you have two "either/or" forms - regular, and irregular - which is something that db's aren't particularly good at handling as relationships.
One possible (programmatic) solution would be to simply have a "plural" column in your "word" table, which contains either:
(a) A suffix, denoted by a '-' in the first character: eg, "-es". (b) A complete word: eg: "elves". You could do the same thing with two columns: 'plural' and a boolean 'suffix?', which is probably slightly more "database-y"; but I kind of like the single column approach because it's more visual.
One other thing: Your "lesson_has_words" table is not normalized - at least not to 3rd normal form - and the 'student_ID' is the problem. If the lesson contains the same words for all students, then student_id is redundant.
What I think you're missing is an "Attendance" ('student_has_lesson') table. If the 'words' for a specific lesson can be different for each student, then your "lesson_has_words" table should be {attendance_id, word_id}; if not, then just {lesson_id, word_id}.
HIH
Winston
Winston Gutkowski wrote:
Which raises a question: I've always wondered why JDBC, or databases in general, don't support an 'insert' function that returns the ID.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Thanks for that, Ivan.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |