New answers tagged

1

When you only needed to deal with Transactions, then a single Transactions table was sufficient. Now you need to know about summarisations at the Account level. Yes, you could calculate these dynamically, but this will get progressively slower the more Transactions you have to trawl through. This isn't a User Experience decision. How often will a User ...


6

It depends on what you're willing to do in terms of architectural/performance payoffs. It sounds like at the core you're doing a kind of Event Sourcing, which actually makes a lot of sense when you start talking about domains where it's important to have audit-trails for exactly what happened. I think a key-point for avoiding "code rot" is to make sure that ...


4

How do you know how many rows to skip? Indexes are definitely the way to go, that's what they are for and are usually the fastest way to access data by some criteria (remember to update index statistics regularly, in MySQL using "analyze table"). Not sure what you mean by "redundant", "too much work" or even "too slow". You can also skip rows like @Wyzard ...


0

You can use LIMIT 5, 10 or LIMIT 10 OFFSET 5 to retrieve 10 rows starting from row 5. Row numbers start from 0, so "row 5" is actually the sixth row. (The LIMIT 5, 10 syntax is specific to MySQL; LIMIT 10 OFFSET 5 is works in PostgreSQL too.) Note that unless your query includes an ORDER BY clause, the results are retrieved in arbitrary order, so it ...


3

... I get date from input date type html tag I'll wager you don't. Html tags tend to return String values. You have to parse (and, in this case, format) that [String] value before using it in SQL. Why Parse? Because the Html Control returns a String and you need a Date. Why Format? Because that Date value needs to be represented in the format ...


0

An interesting question. Lets leave aside the question of how to represent reposts. Presumably you will have many types of 'post' some of will be sharing some sort of meta data. The main thrust of your problem is whether to store to data of the post multiple times, once per follower, or have a single copy for the poster and dymamically generate 'feeds' ...


0

a) Don't really understand why you're using $_SERVER variable... I'm always passing localhost (or whatever) from static config. b) Personally I'm using MySQLi, but my connection functions aren't that much different. Never heard about the need or way to make it more secure. It's already very secure as far as I'm aware. You can use SSL if you're connecting to ...


0

If you want flexibility and some ease in managing the data, you'll create a separate table and link them, but if you have minimal requirements and performance is a concern, you can put them all into one. The other developer may have decided there was no need to select specific IPaddresses or get a count of the number of IP Addresses each entity has, so why ...


1

Always use a separate linked table for storing “multiple x for each y” type data. First normal form requires that each field in a row contain an atomic value – that is, a value which is not divisible into multiple sub-values. In case you’re wondering just how useful a separate table will be, compared to a comma-separated list in a single column, consider ...


4

If you see someone putting different "things" into a single database table using a delimiter to keep them separate, that's a problem. It could be that someone does not have permission to change the database structure or that they just don't "get" databases. Either way, it's a performance and maintenance headache. In your situation I would probably ...


6

Yes, there is a very significant downside. If you make a mistake in the code then you get invalid data in the database. Constraints prevents you from entering invalid data in the database. Constraints also prevent you from entering invalid data directly through SQL independent of the application. Of course if you never ever make bugs and mistakes, then you ...


3

As long as you have appropriate indexes for your queries you should be fine. You have formally defined the relationships in your sql select statements, which presumably are checked into the code. I think its fairly common practice to skip foreign key constraints, if you are a dev creating your own DB for use only by one app. It can save you some time ...


0

If it's easy to do it with queries, do it with queries. It sounds like the whole thing should be a stored procedure. As others have said, I don't think a unit testing framework will be much help to you here.


0

You seem to be labouring under a misapprehension about unit testing. Good unit tests adhere to FIRST principles: Whilst this may well be a valid test of your business rules, it clearly isn't a repeatable test since the source data can change over time. What you can do is write unit tests to create various data scenarios and check that your business rules ...


5

Been there, done that. First let's make something clear: That's not unit testing. Unit testing is about code. You are not runnning the tests after a code change to test if code alterations introduced a bug or unwanted behavior. Instead you want to run some routines at the end of a business day to see if some business performance indicator has met some ...



Top 50 recent answers are included