database

How do you maintain revision control of your database structure?

What is the simplest way of keeping track of changes to a projects database structure? When I change something about the database (eg, add a new table, add a new field to an existing table, add an index etc), I want that to be propagated to the rest of the team, and ultimately the production server, with the minimal fuss and effort. At...

Handling a lost database connection with SubSonic 2.2

Hi, I have a long running process - Windows Service which is using SubSonic 2.2 for database access - in this case, accessing a SQL 2005 database. (I can't move to SubSonic 3, as we can't use .NET 3.5) This service is polling a database table (amongst other things). I would like to handle the event where it loses the database connectio...

To check `0 rows` from the SQL query in Postgres / PHP

How can you check an empty database result and then make an action based this? My code which puts matching result to the if -clause while( $tags_and_Qid = pg_fetch_array( $result_tags )) { // Add the Tag to an array of tags for that question $end_array [ $tags_and_Qid['question_id'] ] ['tag'] [] = $tags_and_Qid['tag']; ...

db optimization: computing rank

This question asks how to select a user's rank by his id. id name points 1 john 4635 3 tom 7364 4 bob 234 6 harry 9857 The accepted answer is SELECT uo.*, ( SELECT COUNT(*) FROM users ui WHERE (ui.points, ui.id) >= (uo.points, uo.id) ) AS ran...

Ruby on Rails: One to many relationship view

New to rails and trying to get a one to many relationship up and running. I have it working in the Model and Controller, but I'm having trouble getting it up and running in the views. class Project < ActiveRecord::Base has_many :non_labor_expenses end class NonLaborExpense < ActiveRecord::Base belongs_to :project end I manually c...

Automatically generated test data to a DB from a schema?

I have a discussion-db, and I need a great amount of test data, for different sized samples. Please, see the ready SELECT, JOIN and CREATE-queries, please scroll down in the link. How can I automatically generate test data to the db? How to generate test data in different sized samples? Is there some ready tool? ...

Performane improvement in getting paged data for asp.net grid

I am encountering a performance problem in the development of current UI. The problem, I suppose, is however general. I have a page with a simple asp.net grid. Grid will display data from a table based on certain search criteria. Moreover, grid has fixed page size (say 10). There is pager at the bottom which can be used to navigate b/w...

Making a drupal database call using ajax

I want a link that when you click on it, it will call a simple ajax query which updates a database entry. Normally this would be easy, but because authentication needs to happen before the query is executed, I need to be able to execute the Ajax Query AS THE CURRENTLY LOGGED IN USER. I.e. I need access to the $user variable and I don't w...

union with join to common table

I've got a query that presently looks something like this (I'll simplify it to get to the point): select shipment.f1, type1detail.f2 from shipment join type1detail using (shipmentid) where shipment.otherinfo='foo' union select shipment.f1, type2detail.f2 from shipment join type2detail using (shipmentid) where shipment.otherinfo='foo' ...

What DB for big databases?

I'm embarking on a project which will likely cross several million rows in the short future, so I am researching the database I use as that is sure to prove an issue. From what I have read, SQL in all its incarnations has issues once you get to the 2,000,000 rows issue for a table. Is there a good database recommended for these big size ...

Django query for large number of relationships

I have Django models setup in the following manner: model A has a one-to-many relationship to model B each record in A has between 3,000 to 15,000 records in B What is the best way to construct a query that will retrieve the newest (greatest pk) record in B that corresponds to a record in A for each record in A? Is this something tha...

SQL Server Database Schemas

I use schemas in my databases, but other than the security benefits and the fact that my OCD is happy, I don't really know whay it is good practice to use them. Besides the more granular security, are there other reasons for using schemas when building a database? ...

Examples of "when is good idea implement many-to-many relationships"?

I ask this because need to understand/explain better with examples. clasical examples like: an Article can be published in multiple Publication objects, and a Publication has multiple Article objects. (source) I see is usefull for web2.0 for sharing features. ...

select the maximun

i have a table sou_id sou-name rool_upid roll_upname 1 AA null null 2 BB null null 3 CC null null 1 DD null null 2 EE null null 5 CC null null i need to first use an update stateme...

JavaScript/VBScript SQL Database

I need information on JavaScript/VBScript with SQL database. I'm currently doing scripting. My problem is, in scripting, how to connect and insert some data to a MySQL database. I did find something mentioning on client/server side database. Do I need to consider that also? I'm not building the application for the Web services. ...

need a sql query to wrap text coming in differnt colums to one column

i am running the following query SELECT ora_database_name AS SERVER_NAME,'CNTODSSTG' AS DB_NAME,p.owner,p.object_name,s.text FROM all_procedures p,all_source s WHERE p.owner<>'SYS' AND p.owner<>'SYSTEM' AND s.TYPE='PROCEDURE' AND p.object_name=s.name GROUP BY p.owner,p.object_name,s.text s.text is the coding inside the procedure. Bu...

Oracle Schema Doubt?

Currently am using postgres with diff schemas for diff modules.Now i am planning to switch towards oracle.But i heard that in oracle schema is not there..Is it true..if it is like that how can i migrate? ...

Synchronize Excel and XML data?

Hi, I've got an XML file which is a pain to manually update. So I was thinking of creating a small app which synchronizes this data for me based on data from an Excel Sheet or something. Could anyone point me in the right direction for this? Or does some software already exist for this purpose? The XML schema looks like this: <Data> ...

Need data from a many:many join in a Rails view

Its maybe not the best solution in most cases, but i want a table with data form 3 tables. class Media < ActiveRecord::Base belongs_to :user belongs_to :type has_many :ratings end class User < ActiveRecord::Base has_many :medias has_many :ratings end class Rating < ActiveRecord::Bas...

Generate database schema from NHibernate mapping

Is it possible to generate the database schema from the Nhibernate mappings DLL? My requirements is for MySQL. If so, how do I do that? Are there tools/scripts for this? Open source/freeware tools? Additionally, can I use these tools to insert/update datasets to the database? ...