database

Whats the best way to retrieve information from Sphinx (in PHP)?

I'm new to sphinx, and I'm seting it up on a new website. It's working fine, and when i search with the search in the console, everything work. Using the PHP api and the searched, gives me the same results as well. But it gives me only ids and weights for the rows found. Is there some way to bring some text fields togheter with the 'mat...

Storing SQL field names and general SQL usage with Delphi

I'm starting to write my first Delphi application that connects to an SQL database (MySQL) using the ADO database components. I wondered whether there was any best way of storing the names of the fields in the database for easy reference when creating SQL queries later on. First of all I made them a simple constant e.g. c_UserTable_Us...

Preferred Method of Storing Passwords In Database

What is your preferred method/datatype for storing passwords in a database (preferably SQL Server 2005). The way I have been doing it in several of our applications is to first use the .NET encryption libraries and then store them in the database as binary(16). Is this the preferred method or should I be using a different datatype or all...

SQL Insert Performance Improvement

I am writing an application that logs status updates (GPS locations) from devices to a database. The updates occur at a set interval for each device, which is currently every 3 seconds. I'm using a simple table in SQL Server 08 for storing each update. I've noticed that running the inserts is an area of slow down in my application. I...

Why django checks whether settings.DATABASE_NAME db actually exists for running testcases?

I will be frequently running testcases for my django project. But one fine day it occured to me that django actually checks the settings.DATABASE_NAME db actual existence while running testcases. Why is this so. All I thought was django will be taking the settings.DATABASE_NAME and creates a test db called 'test_' + settings.DATABASE_NAM...

What is the best way to associate a file with a piece of data?

I have an application that creates records in a table (rocket science, I know). Users want to associate files (.doc, .xls, .pdf, etc...) to a single record in the table. Should I store the contents of the file(s) in the database? Wouldn't this bloat the database? Should I store the file(s) on a file server, and store the path(s) in t...

When to do stored procedures and when not to

This is just a general discussion on what is the best occasion to use stored procedure! Personnally i have very low opinion on stored procs becouse; 1. they tie you to one particular database enviroment and 2. the idea of shuffling back and fourth between your interface code and the back-end enviroment for the stored procs its a nightmar...

Log query before executing it.

Hi, I've run into a problem where I run some query and the mysqld process starts using 100% CPU power, without ending. I want to pinpoint this query. The problem is that log/development.log contains only queries that have finished. Any idea? ...

Problem facing while inserting data into dynamically created column of table.

Hi all, I am dynamically adding column to table in db through code using alter table query. But i am facing problem wen i am trying to insert values in that column. it throws an exception column does not exists. And wen i clean and rebuild my project through netbeans it works fine. I am using java and mysql as databse . Is there any...

Select from multiple tables where one has distinct values

I have a simple problem here using SQL views. I just can't seem to figure it out at the moment. I have 2 tables, TableA and TableB. I want to retrieve FieldA in TableA and FieldB in TableB. The two tables are linked using an INNER JOIN. I only want rows where TableA.FieldA are distinct. The returned values should be of the top 10 items...

Building up a monthly total from past 12 months

CurrentMonth = Month(CurrentDate) CurrentYear = Year(CurrentDate) SQL = "SELECT Spent, MONTH(Date) AS InvMonth, YEAR(Date) As InvYear FROM Invoices WHERE YEAR(Date) = '" & CurrentYear & "' AND MONTH(Date) = '" & CurrentMonth & "'" RecordSet.Open SQL, Connection, adOpenStatic, adLockOptimistic, adCmdText Do Until RecordSet.EO...

.Net inserting NULL values into SQL Server database from variable values

Hi. There have been similar questions but the answers weren't what I was looking for. I want to insert the a value of NULL into the SQL Server database if the reference is NULL or a value has not yet been assigned. At the moment I am testing for null and it looks like String testString = null; if (testString == null) { command.Para...

Marrying up consumer-defined aggregates (e.g. SQL counts) with 'pure' model objects?

What is the best practice of introducing custom (typically volatile) data into entity model classes? This may sound like a bad practice first, but it seems to be quite a common scenario. In our recent web application we have developed a proper model and in most cases we are fine with loading model entities. But there are cases where we c...

Creating a new text column in a SQL Server Table: which type should I choose?

I have a text field that can be 30 characters in length, however it can achieve around 2.000 characters. For "future safety", it would be nice if this new column could support until 3.000 characters. I think the average size of this field is 250 characters. Which SQL Server 2000 data type is better to increase performance and disk spac...

How do you hide an encryption key in a .NET application?

I'm developing an intranet application (C#) that uses some data (local to the web server) that we'd like to keep private. This data is encrypted (AES) using a legacy data repository. We can't totally prevent physical access to the machine. Clearly, we're never going to have perfect security here. However, we want to make it as hard as p...

.NET and database layers

When I last worked in programming, we were trying to move away from DataReaders and the traditional ADO.NET API toward Object Relational Mapping (ORM). To do this, we generated a DataContext of our DB via sqlmetal. There was then a thin data layer that made the DataContext private, and any code needing to access the database would have ...

How do I manage identities with ETL?

I need help figuring out a workflow and I'm not sure how to go about it... Let's say I'm transforming (ETL?) data from Table A to Table B. Table A has a composite primary key A.a+A.b+A.c, while Table B has just an automatically populated identity column. How can I map the composite keys from A back to the identities created when insertin...

Personal names in a global application: What to store.

Storing personal names in a structured way seems quite difficult when it comes to an application which is used by users from lots of different countries. The application I'm working on could theoretically be used by anyone from any place in the world. Most often a given name (first name / forename) and surname seems to be used. In which...

Retriving live data to a DataGrid

I have a table where constantly records are inserted in, so I like to monitor this records in a DataGrid showing e.g. the 1000 last records inserted; but also, I want to show it like if this grid is a live view of what's happening on the table, some sort of tailing a file. I've thought many ways to do it, for example, I could every five...

Does Postgres have something similar to Oracle's Virtual Private Databases?

As the title suggests, does anyone know if such a thing exists? ...