New answers tagged

1

Cursors can be the preferred solution, but more often than not, they're [ab]used for logic that would be better implemented using joins, case statements, whiles etc. You state this logic: C = A + B D = C + B But is D really dependent on C? Could you not write all the derived columns as a series of long hand statements e.g. C = A + B D = A + B + B If ...


10

I would use a series of with clauses: WITH some_stuff AS ( SELECT ... FROM ... INNER JOIN ... ON ... ), some_stuff_with_c AS ( SELECT *, a + b AS c FROM some_stuff ), some_stuff_with_d AS ( SELECT *, b + c AS d ) ... and wrap it all up in a view. I think this is pretty easy to understand, It's just a list of column definitions. ...


1

The question is already a bit aged, but maybe someone still stumbles upon it. Most of the mvc-based PHP frameworks offer a feature called scaffolding. With this feature you can easily create simple masks for CRUD operations. Instead of ids ususally a display-field is used for defining relations. I often use CakePHP to achieve what you describe, but it ...


0

The ANSI SQL standard does not require hash indexes. Several relational database products have chosen hashing as an index implemention, however. PostgreSQL allows them to be explicitly declared. SQL Server uses hashing in its in-memory OLTP engine. Also, one way of implementing a SQL JOIN condition is to use hash tables, though these hash tables live only as ...


0

I suggest using the Command pattern and an Event Store. Instead of complete revisions of a document, break each change down into a command. Ie InsertTextAt(...) Store the data needed to execute the command in the db. As the user edits the document you build up a list of these commands. When you recreate the document you load all the commands from the db ...


3

Hash tables allow you to very quickly lookup an item if you have the exact key. Hash tables cannot handle a request like "give me all invoices issued from the 2nd to the 15th of April". A lot of a time a database access wants all data in some range of values. Search trees work a lot better for that.


0

What you are doing seems reasonable, the only trick is you'll need to insert the Document with null revisions, then add the revisions, then update the Document. When adding revisions, you just add the revision then update the Document. An alternative approach is to have "current" and "published" flags on the revisions. If you have partial unique index ...


2

Here's my two cents. If you want to know the current revision you should query the REVISION table for the max(revision_id) for that document_id. The same for PUBLICATION. You can have a view V_DOCUMENT with that already resolved via a join, so to the programmers it would be as if there's a V_DOCUMENT "table" with a CURR_REV_ID and a CURR_PUB_REV_ID. If you ...


1

First: naming. The table called "Documents" above stores knowledge of revisions, not docs or contents. Perhaps it could be called "DocumentRevisions". Second: separate the document bodies table's index pk from document id, and store variations on the document body in the table with the same document id, yet different table index. In the end you get: ...


4

I shall talk about how Microsoft SQL Server handles this, as that is the DBMS with which I am most familiar. The SQL received by the server is converted into a series of physical operators by the optimiser. The physical operators initialize, collect data, and close. Specifically, the physical operator can answer the following three method calls: Init(): ...


-2

Projection = columns of record you want to fetch... Selection = puts condition to select specific rows selectionArgs = the condition by which rows are filtered.. in above example... projection = * i.e. all columns selection = name i.e user want to filter records according to this column selectionArgs = zesus i.e records related to zesus are fetched. ...


1

You actually need to create a Data Access Layer: 1- Create a New Class Library [ProjectName].DataAccess 2- Create a Class Named UserManager. 3- Create a Method called AddUser that takes the User Model as an argument. and inside that method, you write the logic to insert the user to the database. Depending on the Scale of your system, you might want ...


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