database

How do you recommend implementing tags or tagging

I've heard of a few ways to implement tagging; using a mapping table between TagID and ItemID (makes sense to me, but does it scale?), adding a fixed number of possible TagID columns to ItemID (seems like a bad idea), Keeping tags in a text column that's comma separated (sounds crazy but could work). I've even heard someone recommend a s...

updating an auto_now DateTimeField in a parent model w/ Django

I've got two models: Message and Attachment. Each attachment is attached to a specific message, using a ForeignKey on the Attachment model. Both models have an auto_now DateTimeField called updated. I'm trying to make it so that when any attachment is saved, it also sets the updated field on the associated message to now. Here's my code:...

List of standard lengths for database fields

I'm designing a database table and once again asking myself the same stupid question: How long should the firstname field be? Does anyone have a list of reasonable lengths for the most common fields, such as first name, last name, and email address? ...

Represent Ordering in a Relational Database

I have a collection of objects in a database. Images in a photo gallery, products in a catalog, chapters in a book, etc. Each object is represented as a row. I want to be able to arbitrarily order these images, storing that ordering in the database so when I display the objects, they will be in the right order. For example, let's say...

Unit-Testing Databases

This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit testing was one of the requirements. I ran into some trouble when I tried to test against the database. To my understanding, unit tests should be: stateless independent from each other repeatable with the same results i.e. no persisting changes These re...

Is it possible to share a transaction between a .Net application and a COM+ object?

I did some tests a while ago and never figured out how to make this work. The ingredients: COM+ transactional object (developed in VB6) .Net web application (with transaction) in IIS that... makes a call to the COM+ component updates a row in a SQL database Testing: Run the .Net application and force an exception. Result: The...

How do i resize and convert an uploaded image to a PNG using GD

I want to allow users to upload avatar-type images in a variety of formats (GIF,JPEG,PNG at least), but to save them all as PNG database BLOBs. If the images are oversize, pixelwise, i want to resize them before DB-insertion. What is the best way to use GD to do the resizing and PNG conversion? Edit: Sadly, only GD is available on the ...

What's a good way to encapsulate data access with PHP/MySQL?

Most of my experience is on the MSFT stack, but I am now working on a side project, helping someone with a personal site with cheap hosting that is built on the LAMP stack. My options for installing extras are limited, so I'm wondering about how to write my data access code without embedding raw queries in the .php files. I like to kee...

How to filter by 2 fields when loading data into an access database table from an excel spreadsheet

OK, here is my problem, without being too specific for reasons of being fired for putting company practices on the internet. There are spreadsheets made. These are uploaded to the database. I need to filter out duplicates from uploading. The only way to do this is by making sure that for each and every entry that two fields aren't the s...

Where to put your code - Database vs. Application?

Hello, I have been developing web/desktop applications for about 6 years now. During the course of my career, I have come across application that were heavily written in the database using stored procedures whereas a lot of application just had only a few basic stored procedures (to read, insert, edit and delete entity records) for each...

What is the best way to communicate with a SQL server?

I am going to be using c/c++, and would like to know the best way to talk to a MySQL server. Should I use the library that comes with the server installation? Are they any good libraries I should consider other than the official one? ...

Good strategy for leaving an audit trail/change history for DB applications?

What are some strategies that people have had success with for maintaining a change history for data in a fairly complex database. One of the applications that I frequently use and develop for could really benefit from a more comprehensive way of tracking how records have changed over time. For instance, right now records can have a numb...

To what extent should a developer learn database?

Modern Databases systems today come with loads of feature. And you would agree with me that to learn one database you must unlearn the concepts you learned in another database. For e.g. each database would implement locking differently than other. So to carry the concepts of one database to another would be a recipe for failure. And ther...

Select existing data from database to create test data

I have a SqlServer database that I've manually filled with some test data. Now I'd like to extract this test data as insert statements and check it in to source control. The idea is that other team members should be able to create the same database, run the created insert scripts and have the same data to test and develop on. Is there a...

Zip Code Database

Are there any open source/free databases for US zip codes? ...

What is the "best" way to store international addresses in a database?

What is the "best" way to store international addresses in a database? Answer in the form of a schema and an explanation of the reasons why you chose to normalize (or not) the way you did. Also explain why you chose the type and length of each field. Note: You decide what fields you think are necessary. ...

Stored Procedure and Timeout

I'm running a long process stored procedure . I'm wondering if in a case of a timeout or any case of dis-connection with the database after initiating the call to the stored procedure, Is it still working and implementing the changes on the server? ...

joining latest of various usermetadata tags to user rows

I have a postgres database with a user table (userid, firstname, lastname) and a usermetadata table (userid, code, content, created datetime). I store various information about each user in the usermetadata table by code and keep a full history. so for example, a user (userid 15) has the following metadata: 15, 'QHS', '20', '2008-08-24 ...

SQL Insert into ... values ( SELECT ... FROM ... )

I am trying to insert into a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the SQL-Engine of the day (MySQL, Oracle, SQLServer, Informix, DB2). I've been wondering if there is a silver-bullet syntax coming from an SQL S...

How is data compression more effective than indexing for search performance?

For our application, we keep large amounts of data indexed by three integer columns (source, type and time). Loading significant chunks of that data can take some time and we have implemented various measures to reduce the amount of data that has to be searched and loaded for larger queries, such as storing larger granularities for queri...