03-02-2023, 07:12 PM
(This post was last modified: 03-02-2023, 10:08 PM by SpriggsySpriggs.)
Is it just a flex that people are always trying to write up databases in QB64 rather than just use database tools to make and edit databases? If someone plans on putting some of this code out in a "production" environment, it might be well worth their time and give them some peace of mind to use something that's tried and true rather than being responsible for not only making the database, but also making all the code that maintains it. This might sound like a SQLite or MySQL plug and it is. Database queries are not hard and don't have to be. If I want all grades for a student from the year 2023? "SELECT * FROM Gradebook WHERE FirstName = 'Balderdash' AND LastName = 'Poppycock' AND Year = '2023'"
Boom. Now you've got everything pertaining to that student for that year. Oh, you also want to know the average for his grades? "SELECT AVG(PercentGrade) FROM Gradebook WHERE FirstName = 'Balderdash' AND LastName = 'Poppycock' and Year = '2023'"
What's that? You want to update his grade for History? "UPDATE Gradebook SET LetterGrade = 'A' WHERE FirstName = 'Balderdash' AND LastName = 'Poppycock' AND Subject = 'History' AND Year = '2023'"
Obviously, I've simplified that gradebook logic down a bit to show basic usage but it really is that easy. Now you don't need some crazy binary file with records and fixed length strings to emulate arrays and some handwritten algorithm for accessing, reading, and writing all that nonsense. Someone is going to ask me to give an example of MySQL but the Wiki example has worked and does still work. It's not the best, but it does work. If there is enough interest in making your lives easier and doing databases the right way, I'll possibly make a post explaining in detail how to do SQL. From the ground up. The whole 9 yards. From the software installations to the database creation to the database connection to the client configuration to the basic query usage.
Before I'm reminded that I promised a SQL tutorial back on the old forum, I know. I know.
P.S. SQLite would be better suited for a local application that will not need to keep all the information centralized. If you want a server to host the data, use MySQL.
Boom. Now you've got everything pertaining to that student for that year. Oh, you also want to know the average for his grades? "SELECT AVG(PercentGrade) FROM Gradebook WHERE FirstName = 'Balderdash' AND LastName = 'Poppycock' and Year = '2023'"
What's that? You want to update his grade for History? "UPDATE Gradebook SET LetterGrade = 'A' WHERE FirstName = 'Balderdash' AND LastName = 'Poppycock' AND Subject = 'History' AND Year = '2023'"
Obviously, I've simplified that gradebook logic down a bit to show basic usage but it really is that easy. Now you don't need some crazy binary file with records and fixed length strings to emulate arrays and some handwritten algorithm for accessing, reading, and writing all that nonsense. Someone is going to ask me to give an example of MySQL but the Wiki example has worked and does still work. It's not the best, but it does work. If there is enough interest in making your lives easier and doing databases the right way, I'll possibly make a post explaining in detail how to do SQL. From the ground up. The whole 9 yards. From the software installations to the database creation to the database connection to the client configuration to the basic query usage.
Before I'm reminded that I promised a SQL tutorial back on the old forum, I know. I know.
P.S. SQLite would be better suited for a local application that will not need to keep all the information centralized. If you want a server to host the data, use MySQL.
Ask me about Windows API and maybe some Linux stuff