database

Is denormalizing acceptable in this case?

I have the following locations table: ---------------------------------------------------------- | ID | zoneID | storeID | address | latitude | longitude | ---------------------------------------------------------- and the phones table: ----------------------- | locationID | number | ----------------------- Now, keep in mind that f...

How can I SELECT+INSERT in the same mysql query?

I have a php script that process keywords from a mysql table "keywords" (columns: id - keyword) and then it saves data into another table "data" (column: id[foreign key keywords.id] - dataname - datavalue). My problem is that when the script is ready to save the data I only have the keyword and not the id. So is there a way I can get t...

sql server database file size already 4 gb but not so much data in it

I checked the size of the file itself - it said it's 4.02 GB. I checked the size mentioned in properties of the database using SSMSE - it said the size was somewhere above 4000 MB. I then executed sp_spaceused and it said that the file size was above 4500 MB and the unallocated space was close to 4100 MB. I'm a little confused as to ho...

MySQL: Multiple Photos and Videos for News with Joins

I want multiple photos and multiple videos, the main problem is that I can't get them inline if I don't use joins. So for example, I get 2 photos a video and again a photo. I have a parent news table and 2 secondary table news_photos and news_videos and I want to get in one query the photos and videos for the news. Is this somehow pos...

Web application for managing elections campaign

I’m trying to help a friend in his election campaign. We mainly need a tool to manage a list of possible voters. We need to be able to: 1. Easily update details about the voters, and 2. Query for voters according to various parameters, and show and print the resulting lists To enable campaigners to work from multiple workstations, we wo...

Sub version for database (i want something for data values in the database, not for the schema)

I am using github for maintaining versions and code synchronization. We are team of two and we are located at different places. How can we make sure that our databases are synchronized. Update:-- I am rails developer. But these days i m working on drupal projects (where database is the center of variations). So i want to make sure t...

Why is MySQL auto_increment skipping numbers.

We are running an import of an existing product table into a new table of our own. The import script we've written runs perfectly and inserts the right amount of rows (6000 or so). However, after the import the next auto incremented primary key/id is 1500 entries (or so) above the number of rows in the table. We can't understand why MyS...

Creating database constraints on tables on the fly

I am creating tables from java on the fly as they are needed. Now to define constraints and indexes on these tables we need to come up with unique names. I am planning to query the system views to get the constraint and index system views to get a list of all existing names and then come up with a random name and check against these val...

How to generate secure passwords for new users?

I have a list of students that are being added via a form inside the admin area. I'm trying to come up with a password generating solution for each addition that will be both secure and viewable from the admin panel (like below). I need it to be viewable so that the admin will be able to print out the passwords and hand them out to th...

Google App Engine - Tracking which indexes are used

I have a App Engine/Python/Django application which has grown and been modified over the past year and currently has 175 indexes. The problem is that I have not been thourough in cleaning up/removing indexes that are no longer needed. Now, I am not sure which indexes are active and which are essentially dead, but I am guessing that abou...

How should i have my connection to the database

Hii , I am developing an application where I ran across into this problem ...I have this GUI where in I have many buttons ... Each button performs some action like INSERT , SELECT , UPDATE , DELETE , VIEW etc... on a database . My question is ... Is it better to have a single connection open for the entire lifetime of this particular...

How to securely store database credentials for Windows application?

I have a python application designed to run as a service on Linux, and I've been asked to install it on a Windows XP box in an office where there are no Linux machines (for me, this makes it a bizarre and confusing place as I have virtually no experience developing for Windows). On Linux the application has its own user, and the applica...

EMPTY_CLOB() in Microsoft SQl server

Hey guys, Oracle has a CLOB type and the function EMPTY_CLOB(). I'm looking for an alternative for use in SQL server. Thanks in advance. ...

mysql query help, getting values from table using relational id's from another table

THE SQL THAT BUILDS THE TABLES, -- -- Table structure for table `careers` -- CREATE TABLE IF NOT EXISTS `careers` ( `career_id` int(11) NOT NULL auto_increment, `career_name` varchar(75) NOT NULL, `career_desc` text NOT NULL, `degree_needed` enum('Yes','No') NOT NULL, `useful_info` text, `useful_links` text, PRIMARY K...

Syncing Drupal site between dev, staging and production

Hi all, Often after a Drupal (6.x) site is launched, I have people starting to sign up and enter their own content. Whenever there is need for an upgrade, the database on production is copied to dev and then the development is done on dev, later get pushed to staging for client's approval. When the site is eventually ready to go live...

mysql insert command syntax

I am using MYSQL 5.1, I am trying to write an insert statement in my java class. It sounds very simple but i tried and getting exception. I am sure there is a syntax error with my code. below is the snippet could any one help me out here. ID is in primary key atm_ID is varchar trasn_id is varchar sysDate is Date rest is int please he...

Entity Framework and Connection Pooling

I've recently started to use the Entity Framework 4.0 in my .NET 4.0 application and am curious about a few things relating to pooling. Connection pooling as I know is managed by the ADO.NET data provider, in my case that of MS SQL server. Does this apply when you instantiate a new entities context (ObjectContext), i.e. the parameterle...

Hibernate : Foreign key has the wrong number of column. should be 0

Hi , I am trying to evaluate a mapping in this Hibernate document : section 2.2.3.1. Generating the identifier property http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-mapping-identifier In the document , Person and MedicalHistory has @OneToOne mapping (MedicalHistory points to Person) , and the do...

Is storing a comma separated list in a database column really that bad?

Imagine a web form with a set of checkboxes (any or all can be selected). I chose to save them in a comma separated list of values stored in one column of the database table. Now, I know that the correct solution would be to create a second table and properly normalize the database. One reason was laziness, my SQL knowledge is very limi...

How do you avoid this race condition in Python / Django / MySQL?

I have a model MyModel that has a field expiration_datetime. Every time a user retrieves an instance of MyModel I need to first check if it has expired or not. If it has expired, than I need to increment some counter, update others, and then extend the expiration_datetime to some time in the future. So the view would do something ...