database

Zend Framework: Proper way to interact with database?

I'm fairly new to the Zend Framework and MVC and I'm a bit confused by Zend_DB and the proper way to interact with the database. I'm using the PDO MySQL adapter and have created some classes to extend the abstract classes: class Users extends Zend_Db_Table_Abstract { protected $_name = 'users'; protected $_primary = 'user_id'; ...

Auto refresh web page

I have a web page which allows the user to carry out various operations that in turn modify the database. Also, this web application needs to keep track of various fields in database that keep changing with time. Is refreshing the page every few seconds the best possible way to implement this? For example, if there is a long list on the ...

Fixing DB Inconsistencies - ID Fields

I've inherited a (Microsoft?) SQL database that wasn't very pristine in its original state. There are still some very strange things in it that I'm trying to fix - one of them is inconsistent ID entries. In the accounts table, each entry has a number called accountID, which is referenced in several other tables (notes, equipment, etc. ...

Is it ok to use character values for primary keys?

Is there a performance gain or best practice when it comes to using unique, numeric ID fields in a database table compared to using character-based ones? For instance, if I had two tables: athlete id ... 17, name ... Rickey Henderson, teamid ... 28 team teamid ... 28, teamname ... Oakland The athlete table, with thousands of playe...

How to keep code base and database schema in synch?

So recently on a project I'm working on, we've been struggling to keep a solution's code base and the associated database schema in synch (Database = SQL Server 2008). Database changes occur fairly regularly (adding columns, constraints, relationships, etc) and as a result it's not uncommon for people to do a 'Get Latest' from source ...

Using a variable in a query

I am trying to set up a query for my dataset in C# using a variable for the filter. For example I am trying to only display a specific account number and his balance, with a local variable being the account number used as a filter for that exact one. Am I going about this the wrong way? I am in no stretch of the imagination a real progr...

Is there any pattern or refactoring trick to split Enum and DBDictionary data duplicate

We have a smelly code in our project. A lot of values which used in biz logic have 2 places where they stored: we have dictionary tables (used in FK relations) in DB where we stored values e.x. MessageDirectionInfo: 0|Unknown 1|In 2|Out and we have Enum with exactly same data: MessageDirectionEnum{Unknown=0,In=1,Out=2} And all over ...

Need an overview of non-enterprise databases for .NET

For smaller websites which are view-only or require light online-editing, SQL Server 2008, Oracle, and MySQL are overkill. In the PHP world, I used SQLite quite a bit which is a e.g. 100K file holding hundreds of records which you speak to with standard SQL. In the .NET world, what options do we have, I've seen: SQL Server 2008 Expre...

From what do sql parameters protect you?

Parameters are used to protect you from malicious user input. But if the parameter expects a string, is it possible to write input that will be interpreted as sql, so malicious users can use things like 'DROP', 'TRUNCATE', etc...? Are there differences in protection between parameters in asp, asp.net, java and others? See also: Are ...

is it worthwhile to create a connector for SimpleDB?

for a business intelligence software -- are they doing well? ...

Django: Increment blog entry view count by one. Is this efficient?

I have the following code in my index view. latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10] for entry in latest_entry_list: entry.views = entry.views + 1 entry.save() If there are ten (the limit) rows returned from the initial query, will the save issue 10 seperate updated calls to ...

SQL Server simple Insert statement times out

Hi, I have a simple table with 6 columns. Most of the time any insert statements to it works just fine, but once in a while I'm getting a DB Timeout exception: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated. Timeout is set to 10 seconds...

One-way Store and Forward DB Replication Architectural Question

Hi, I am looking for some input please. I am designing a multi-user, mutli-vendor, n-tier database application. Each local installation of this system must replicate its records to a single central server. This server is not directly available to the users of the installed database app and the Internet is the only route to it. The ...

Exporting/Importing Stored Procedures between DBs

I have two SQL Server 2005 databases, one is for development and the other is on the final production server. I would like to know the fastest way of ensuring that the production database has the exact same stored procedures (number and most recent version). Assumptions: Databases have same table schema. Production database is curren...

SQL Server - Syncing two database.

We have a warehouse database that contains a year of data up to now. I want to create report database that represents the last 3 months of data for reporting purposes. I want to be able to keep the two databases in sync. Right now, every 10 minutes I execute a package that will grab the most recent rows from the warehouse and adds the...

handling lookup tables with deleted records and databound controls

I have a table Resource with a field Type. Type is a lookup into the table ResourceType. So for instance ResourceType might have: 1: Books 2: Candy 3: Both And Resource might have 1: Tom's Grocery, 2 2: Freds News, 3 It would display as: Tom's Grocery Candy Now lets say I am using a databound combobox for the resource type and the...

How to best handle the storage of historical data?

I'm trying to determine how I should store historical transactional data. Should I store it in a single table where the record just gets reinserted with a new timestamp each time? Should I break out the historical data into a separate 'history' table and only keep current data in the 'active' table. If so, how do I best do that? With...

What is the difference between Left, Right, Outer and Inner Joins?

I am wondering how to differentiate all these different joins ... ...

Why should you use an ORM?

If you were to motivate the "pros" of why you would use an ORM to management/client, what would the reasons be? Try and keep one reason per answer so that we can see what gets voted up as the best reasons ...

Sql Ansi to manage DateTime values

I'm developing a multi-database system. I want the difference between two dates in seconds. In SQL Server I got: DATEDIFF(second,stardate,enddate) In MySql: TIME_TO_SEC(TIMEDIFF(stardate,enddate)) My question: Does Sql Ansi have functions to manage DateTime values? i.e.: There are datetime functions generic for all databases? ...