database

Complex SQL where clause: whether to factor logic

I've got a complex SQL where clause that just got more complex because of a requirements change. There are four basic sets of cases, each with a different combination of other factors. It's more readable (in my opinion) to have the four cases as separate branches of the where clause, and to repeat the redundant criteria in each branch. B...

I have PHP running on Google App Engine - How do I use DB now?

I followed this to setup PHP on the Google appengine and it works great. Any suggestions on how we can use a database / datastore with this on GAE? ...

How do I use TransactionScope in C#?

I am trying to use TransactionScope, but keep getting the exception below. The app is running on a different machine than the database, if that matters. I am using Sql Server 2005. "Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDT...

Discrepancies between “Mock” Database and “Real” database behaviours.

We use C# and Linq2SQL with a MS SQL Server Database. We have a mockdatacontext to carry out some unit testing. When testing we have discovered two different behaviours depending on whether the "real" or "mock" database is used. Scenario 1: Real Database There are 5 records in the database: db = realDatabase db.InsertOnSubmit(new re...

MySQL Race Conditions

Does this cause a race condition with MySQL (InnoDB): Start Transaction. Try to get record. If record doesn't exist, return. If record exists, delete it and add a log entry saying that is was deleted. End Transaction (commit/rollback). Is it possible for another process to start just before the delete step in 2b, detect the presence ...

Are zip code and postal code violation of 3rd normal form?

Given that state information is implicit in the zip code aren't storing both of them some violaiton of third normal form? Can or should you simply combine them into one field? ...

Update duplicate varchars to be unique in SQL database

I need to change a database to add a unique constraint on a table column, but the VARCHAR data in it is not unique. How can I update those duplicate records so that each value is unique by adding a sequential number at the end of the existing data? e.g. I would like to change 'name' to 'name1', 'name2', 'name3' ...

MySQL FullText search ??

I am working on search functionality in my website. I want to provide a best search mechanism to users. I am using PHP/MYSQL. Let's say user searched for "sport". I have 30 records having word "sport" and 5 records having word "sports" but when I am searching for sport then following query only returns the result 30 who have the word ...

How to reset stop words in MYSQL?

I want to reset stop word list in mysql for FULLTEXT search. I have installed WAMP Server in my system which have phpmyadmin to access mysql. But I dont know how to reset stop word in phpmyadmin. Can anyone please tell me how to do that. I also http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_ft_stopword_file r...

Anything better than P6Spy?

I am planning to use P6Spy to intercept database statements within our architecture. However, I noticed on the P6Spy website that the last release of the software was back in 2003. Is there anything out there that is better or should I just stick with P6Spy? ...

How to change the column order in a SQL Server Compact Edition table schema?

I'm using Visual Studio 2008 to design a SQL Server Compact Edition database (*.sdf). I had to change the schema of one of my tables adding a new column. I want to "move" that new column from the bottom to a different position in the field list. How can I do this in the Visual Studio designer? EDIT: I know that from a pure technical v...

Foreign key is also part of the primary key

Is it possible in plain JPA or JPA+Hibernate extensions to use a foreign key that is also part of the composite primary key? @TableGenerator(name = "trial", table = "third", pkColumnName = "a" , valueColumnName = "b", pkColumnValue = "first") @Entity public class First{ @Id @GeneratedValue(strategy = GenerationType.T...

Is there any way to undelete a SQL server database and stored procedures?

Is there any way to undelete a SQL server database and stored procedures? Edit: No I don't have a backup. That is the reason I need help ...

Generate a Fire Register report

Hello, I am stuck figuring out a working SQL Query for the fallowing: I need to generate a Fire Register report (how many people are still inside the building) based on an Access database that records login/logout events along with some metadata. The Access DB looks like this: +----+---------------------+---------+---------+------+ | i...

Exposing large webservice datasets for consumption by Access or Excel

I have a large dataset, say 1,000,000,000 rows, that lives on a server. I need a user to be able to consume (i.e. "run queries upon") that data seamlessly, over the web, from within Access and/or Excel. Additionally, I need to filter the data on the server-side according to the user connected to it. My current approach is to create a we...

Efficiently sorting data from DB using Java?

What we have: 3 MySQL DB tables: user, text, friend user: username, password, email, etc. text: username, text, date, etc. friend: username, friend_username, etc. Task: Write an algorithm (in Java) to show 10 latest texts from your friends. Ultimate target is to have running time within O(n log n). DB tables can be modified (adde...

Changing a record in a table (sql server) that has foreign keys?

Hi there, Does anyone know if there is a quicker way of editing a record that has foreign keys in a table (in sql server).. i will explain.. i have approx 5 tables that have there own ID but are linked together using a foreign key... Hence i needed to change the foreign key (the contract number in my case), but i had to copy each recor...

How do I connect to an Access 2007 (accdb) file in Visual Studio 2008

I'm in a college class using the Microsoft visual studio 2008 for visual basic and i have a project where i'm supposed to connect a database but it can't recognize the database file as a database. I followed the book exactly so i don't know what the problem is. ...

Do you think of the database or objects first when building applications?

When you think about building an application, say for the web, and it uses a relational database, do you think about the database first and then putting you app as a front end or do you think of your program and objects and how a database can store those. I'm trying to change the way I think but it hasn't clicked (I'm not sure I'm even ...

Hibernate doesn't save and doesn't throw exceptions !?!

Hi, I'm stuck with this already for some weeks and I don't have the faintest idea what's going wrong. I'm quite desparate as I've wasted so much time already I use the data model described below (MySQL). I have created the hbm.xml and java classes by reverse engeneering (Eclipse/JBoss Tools) (see example below). When I try to save tw...