database

Is there a good reason I see VARCHAR(255) used so often (as opposed to another length)?

In multiple courses, books, and jobs, I have seen text fields defined as VARCHAR(255) as kind of the default for "shortish" text. Is there any good reason that a length of 255 is chosen so often, other than being a nice round number? Is it a holdout from some time in the past when there was a good reason (whether or not it applies toda...

Django relation doesnt work?

I have the following in models: class Companies(models.Model): ComName = models.CharField(max_length=255) ComURL = models.CharField(max_length=1024,null=True) class Products(models.Model): PrName = models.CharField(max_length=255) PrCompany = models.ForeignKey(Companies) and the following in the template: {% i...

How to write unit tests for database calls

I'm near the beginning of a new project and (gasp!) for the first time ever I'm trying to include unit tests in a project of mine. I'm having trouble devising some of the unit tests themselves. I have a few methods which have been easy enough to test (pass in two values and check for an expected output). I've got other parts of the co...

Two-way replication with MySQL to sync instances of a database app between multiple offline clients?

I am tasked with building an application whose database backend needs to be replicated in both directions over an unknown number of clients who are usually offline. Before I explain in detail, my question is whether MySQL replication is feasible for this project or if I should look into other technologies. Here's the general use case: ...

Regex - A expert should solve this in seconds

Hi There I were wondering if anyone can help me with a regex I want to insert the following into a database: (#text1#,#text2#,#text3#,#text4#,#text5#,#text6#, #text7#, #text8#, #text9#), (#text1#,#text2#,#text3#,#text4#,#text5#,#text6#, #text7#, #text8#, #text9#), (#text1#,#text2#,#text3#,#text4#,#text5#,#text6#, #text7#, #text8#, #te...

Useful PHP database class

I am working on a small PHP website. I need a MySql database access class that is easy to configure and work with. Does not need to be a full framework, I only need a max. few classes. ...

.NET / Mono Database Engine

Are there any DB engines that are implemented entirely in .NET and Mono compatible? I would like to have a DB solution that will run on all platforms via Mono so that I don't have to worry about having separate native binaries for each platform. ...

How do I do database transactions with psycopg2/python db api ?

Im fiddling with psycopg2 , and while there's a .commit() and .rollback() there's no .begin() or similar to start a transaction , or so it seems ? I'd expect to be able to do db.begin() # possible even set the isolation level here curs = db.cursor() cursor.execute('select etc... for update') ... cursor.execute('update ... etc.') db.com...

Patterns for stored procedures?

Are there any patterns for writing stored procs? like: Should we write 1 Sp for update, 1 for insert and 1 for select for each table. When is it good to create views. How to manage business rules in SP? How to reduce duplicate code etc etc.. Any good article or book to read about these patterns... thanks ...

Storing Data in Files on the Server rather than in Databases?

What are the problems associated with storing your Data in files rather than databases? I'm thinking in terms of something like a blog engiene. I read that MoveableType used to do this. What are the pros/cons of working this way? ...

How do you modify a Domain Class in Grails?

I can't figure how what the "standard practice" is for modifying a Domain Class after it has automatically created the corresponding database table. There's no "migration" in Grails, and there's no way that I can find to tell it to output the new SQL it would generate so you can compare it to the previous table definition and manually i...

Executing scripts from a database project in visual studio

I am trying to add some stored procedure to a build process in visual studio (using MSBuild). I have a database project (*.dbp) added to my solution, however unlike some of the other database projects available in VS i cannot build or run it. ( I believe this is the project file i want as I am using SQL2000) How can i get the SQL scr...

Log usage of database tables, functions, stored procedures, views etc

I work on a system that is based on a SQL server database that has a lot of years of development on it. It is not huge in data volume (a few GB) but it has a lot of complexity (hundreds of tables, hundreds of stored procedures). I want to start by cleaning out the stuff that isn't used any more. We have a weekly/monthly/quarterly/annual...

Ratings to the items based on user click

Hi, I am trying to have a ratings strategy in the hotels search website.Ratings is based on number of clicks by the users who view different hotels.I am trying to assign number of points to each click. Suppose i have a POINTS column in the hotels table which increases by the number of clicks on each hotel, the problem i face is suppose...

How can i print a dbgrid?

I'm working with delphi2009 and i really need to create a button that can print all my data in a dbgrid. I appreciate all the help i can get. ...

Embedded analog of CouchDB, same as sqlite for SQL Server

I like an idea of document oriented databases like CouchDB. I am looking for simple analog. My requirements is just: persistance storage for schema less data; some simple in-proc quering; good to have transactions and versioning; ruby API; map/reduce is aslo good to have; should work on shared hosting What I do not need is REST/HTT...

LINQ to Entities on (database != Microsoft SQL Server)

My production is on full blown SQL Server 2008. I would like to have integration tests with some light weight database that doesn't have to be installed on the machine and doesn't run as a service ...if at all possible. I use LINQ to Entities in my code that probably makes this goal even more complicated. Is it possible to use any...

Good and small open source database for teaching

I need a pet opensource database to learn the principle of database design, can you suggest one for me. ...

Having a List<T>, How to get Other Fields from DB?

Hi I have a method named "GetOrders". This method reads an XML file and gathers OrderNumber of all orders related to a specific user. The method returns a list. Now I wanna to know, having my list, How can I get other fields of these OrderNumbers from DB? ...

Trouble using/displaying special characters from Oracle db in .Net app

I have a C#.Net application that accesses data from a commercial application backed by an Oracle 10 db. A couple of fields in the commercial app's database (declared as varchar2(n)) contain special characters. The "smart quote" apostrophe, for example. The commercial client app displays these characters correctly, but my application i...