Tag Info

New answers tagged

1

You are indeed able to precisely determine what a query will return by using logical reasoning as you described. What SQL does not guarantee is how the engine will find this result. It will give the same result as if it used the logical steps you describe, but how it actually finds the result depends on a number of factors and implementation details. For ...


8

Reasoning about a query's meaning (i.e. the results it should produce) using the naive procedural approach you describe is perfectly fine. As you say, with complex queries it's often the only easy way to work out what's going on. The problem would be if you used this reasoning to infer properties about the query execution (such as time complexity or memory ...


3

Best practice mandates that you should create a separate Attendence table with a foreign key to your Classroom table. Attendence table would have a number for the students attended that classroom that day as well as a date to indicate that particular day. I realize that perhaps you were hoping for a solution that would inline this information into the same ...


0

Since the question is lacking a lot of detail we probably can't work out exactly what you need, but here's a few ideas off the top of my head: You could use a string like "PPPPAPPPPPP" where you pick one letter to mean present and another to mean absent. This makes it easy to add at least a few more "attendance statuses" when you inevitably need them. I ...


-1

SQL databases are very good at handling a very large number of rows. I would go with 1 column because databases are optimized for this. The alternative could easily result in a lot of repetetive code and make it hard to use good abstractions over your database(ORM). Just imagine looping through the 12 columns. Not possible without reflection in a statically ...


0

If you don't use transactions, then yes, there is a minor race condition that can result in having the incorrect value for the total time spent for a brief while. Consider for example the following timing of events: [task 1 added] [total selected] [task 2 added] [total updated] [total selected] [total updated] ...


0

A technique I've used to modify and reorder an arbitrary number of records is to merge/upsert the rows, retaining the auto-incremented IDs and using a separate column to manage sorting. The sort order is tracked by the front-end application and passed as an additional query parameter when saving the records, allowing new records to be placed in any position ...


0

Based on the data you provided I would say this could be made to work both ways. However, since you started off with MongoDB, I will highlight that: First of all, I think you are starting off on the wrong premise: you are trying to cut down on the reads to the database. But MongoDB is designed for fast access to large amounts of data, that's why and when ...


2

We can't answer that. It depends on more than just your schema or lack thereof. It depends also on how you hit the service (in code), how your users hit the application, what sort of caching you're prepared to implement, etc. Use the storage mechanism that is more well suited to how you think and code. Keep interactions with that storage service as isolated ...


0

Mass-removal and mass-insertion of records is an operation done at what is known as "machine time", (as fast as the machine can do it,) and could, perhaps, under some stretch of the imagination, consume the entire 32-bit integer number space of automatically generated keys. But far more reasonable than mass-removal and mass-insertion is an ...


0

You can track what rows the user has modified using the id for that row. Then, update the row that was changed. That should be a simple enough first step optimization and can be implemented in many different ways. I am concerned about the size of the data that you are sending to the user though. Is that really necessary? Normally users are limited to ...


1

Should I separate and create a PHP file for insert and a PHP file to get results from the database? First, you may separate your data access from the business logic by moving data access code to a data access layer. For instance, if the select boxes are populated with the list of countries, then you'll have to call: $this->db->listCountries(); ...


2

I agree wholeheartedly with user61852 on the question of file paths, but can't disagree strongly enough about BLOBS. Although the question doesn't specifically mention if it's a web application or a more traditional client-server application, it sounds like we're talking about a web app from the context provided about USERS & PRODUCTS. If that's the ...



Top 50 recent answers are included