database

How do I keep the variable value in a MySQL stored procedure from changing when records are updated?

I must be overlooking something simple. I'm setting a variable from a query result in a MySQL stored procedure like this: SELECT @myName := username FROM User WHERE ID=1; So, @myName is storing the username of userid 1, which is 'Paul'. Great. But later in the stored procedure I run an update on this record: UPDATE User SET username...

How to create dynamic and safe queries

A "static" query is one that remains the same at all times. For example, the "Tags" button on Stackoverflow, or the "7 days" button on Digg. In short, they always map to a specific database query, so you can create them at design time. But I am trying to figure out how to do "dynamic" queries where the user basically dictates how the d...

Create DB2 History Table Trigger

Hi, I want to create a history table to track field changes across a number of tables in DB2. I know history is usually done with copying an entire table's structure and giving it a suffixed name (e.g. user --> user_history). Then you can use a pretty simple trigger to copy the old record into the history table on an UPDATE. However, ...

Atomic operations in Django?

I'm trying to implement (what I think is) a pretty simple data model for a counter: class VisitorDayTypeCounter(models.Model): visitType = models.CharField(max_length=60) visitDate = models.DateField('Visit Date') counter = models.IntegerField() When someone comes through, it will look for a row that matches the visitType ...

Does persistence ignorance in ADO.NET entity framework mean what I think it means?

If the framework is persistence agnostic, can my unit tests construct a file system version of the persistance store underneath my entity model? I'll be using the model first features of entity framework in the GUI for sure because it's too easy for my devs to make schema changes and keep DAL layer in sync. Has anyone tried using the m...

The best way to import(merge)-export java db database

I have let's say two pc's.PC-a and PC-b which both have the same application installed with java db support.I want from time to time to copy the data from the database on PC-a to database to PC-b and vice-versa so the two PC's to have the same data all the time. Is there an already implemented API in the database layer for this(i.e 1.exp...

Is there an exchange format for ERD ?

Is there a way to exchange ERD diagram from one tool to other as XMI exists for exchanging UML documents? ...

Sending Email alert in SQL Server 2000

Hi would like to send an email alert after checking the result of a query which will return the numbers of rows in a table. Does anyone have any ideas how I could do this in SQL Server 2000 in 2005 I would use a maintenence plan but not sure how in 2000? ...

database encryption

Hi all, I need my database to be secure in case of the hard drive being stolen. I have not seen many databases (even mainstream ones) claiming to support encryption. Do you guys know of any databases that support encryption? If I'm using a database that doesn't support encryption, is it a bad idea to encrypt data natively (using ja...

What's the Hi/Lo algorithm?

What's the Hi/Lo algorithm? I've found this in the NHibernate documentation (it's one method to generate unique keys, section 5.1.4.2), but I haven't found any good explanation of how does it work. I know that Nhibernate handles it, and I don't need to know the inside, but I'm just curious. ...

The Next-gen Databases

I'm learning traditional Relational Databases (with PostgreSQL) and doing some research I've come across some new types of databases. CouchDB, Drizzle, and Scalaris to name a few, what is going to be the next database technologies to deal with? ...

Multiple databases vs a single database

I'm looking at an existing site and they are using separate databases. The databases seem to be setup in the following manner: general types (user_type, language, age, etc) member data (registration information & login) site configuration Personally, I would put everything into 1 database. To me this would make it easier than almost ...

How would you implement sequences in Microsoft SQL Server?

Does anyone have a good way of implementing something like a sequence in SQL server? Sometimes you just don't want to use a GUID, besides the fact that they are ugly as heck. Maybe the sequence you want isn't numeric? Besides, inserting a row and then asking the DB what the number just seems so hackish. ...

Naming an intermediary table in a database

Consider two tables transaction and category each having their own ID and information. A transaction can have more than one category, I have read creating a 3rd table to link transaction and category using their IDs is best. But what would you call this table, assuming you would have many like it? transactionCategories is the best I'm ...

What are the advantages and disadvantages of using a 'Partial Index'?

PostgreSQL allows the creation of 'Partial Indexes' which are basically indexes with conditional predicates. http://www.postgresql.org/docs/8.2/static/indexes-partial.html While testing, I found that they are performing very well for a case where the query is accessing only certain 12 rows in a table with 120k rows. But before we dep...

Automation Error when using ADO/MDAC

OK, struggling to get a definitive answer to this one... I have an application written in VB6 which requires MDAC (2.8 for this installation). MDAC is included in the installer for my application. When the software is removed and re-installed on the same machine MDAC seems to go awry and I receive the following error as soon as my appli...

how to compare list items with mysql table entries

I have a list like listone=[(0,1),(2,45),(0,27),(2,12),(0,45)] which is not stored in mysql database. i want to count similar number of items of the list with comparing mysql table where i store records like the (0,1) item from list is like 0 is one column values1 and 1 is in other column values2 if the both column values are same like...

When does MySQL attempt to update an index for a column?

I'm trying to determine what situations MySQL updates an index. Say I have the following table: CREATE TABLE MyTable ( ID INT NOT NULL AUTO_INCREMENT, MyIndexedColumn VARCHAR NOT NULL, MyNonIndexedColumn VARCHAR, PRIMARY KEY (ID), INDEX MyNewIndex(MyIndexedColumn) ) Then I run the following SQL to insert a row: INSERT INTO...

ASP.NET 2.0: How to bind an asp:Menu to an SqlDataSource?

i've found how to bind an asp:Menu to XML. i've found how to bind an asp:Menu to a site map (which is really binding it to XML). How do you bind an asp:Menu to a database? The .NET Framework provides multiple data sources: HierarchicalDataSourceControl XmlDataSource SiteMapDataSource DataSourceControl SqlDataSource AccessDataSo...

An amnesia patient's "first" functional language? (I really like Clojure...)

I was recently diagnosed with a cascading dissociative disorder that causes retrograde amnesia in addition to an existing case of possible anterograde amnesia. Many people have tried to remind me of how great a programmer I was before -- Right now I get the concepts and the idioms, but I want to teach myself whether I know or not. I thin...