database

Easiest way to obtain database metadata in Java?

I'm familiar with the java.sql.DatabaseMetaData interface, but I find it quite clunky to use. For example, in order to find out the table names, you have to call getTables and loop through the returned ResultSet, using well-known literals as the column names. Is there an easier way to obtain database metadata? ...

In a StackOverflow clone, is it acceptable for Questions and Answers to be separate tables?

Based on the StackOverflow data dump, it seems that S.O. represents questions and answers as a single table - Posts. However, a question has a title, a body and tags associated with while an answer only has a body. To me, at least, this indicates that they are distinct enough that they should be separate tables. Besides, I don't like...

Cascading Delete / Update in LINQ-to-SQL class

Hi, I am not deleting records permanently (just maintaining flag) but I'd like to know how cascading delete / update works in LINQ-to-SQL class. EDIT If I have similar situation e.g. maintaining flag for Delete option. How do you achieve Cascading Delete for your database? ...

How to effectively do database as-of queries?

Excuse the long question! We have two database tables, e.g. Car and Wheel. They are related in that a wheel belongs to a car and a car has multiple wheels. The wheels, however, can be changed without affecting the "version" of the car. The car's record can be updated (e.g. paint job) without affecting the version of the wheels (i.e. ...

Process huge volume of data using Java

As part of the requirement we need to process nearly 3 million records and associate them with a bucket. This association is decided on a set of rules (comprising of 5-15 attributes, with single or range of values and precedence) which derive the bucket for a record. Sequential processing of such a big number is clearly out of scope. Can...

BALD-D battle Against Bad Database Design

I'm no DBA, but I respect database theory. Isn't adding columns like isDeleted and sequenceOrder bad database practice? ...

What is the best local-database solution for WPF applications?

What is currently the best solution for WPF applications which are meant to be used on one computer where various users log into them and use them to get/save information locally? Here's how I see the options: MDF would seem to be the best choice since I assume you can lock it down quite well so that even though users can access the .m...

what is faster query (select name .... or select top(1) name...

Hi what is faster query ? select Name from Worker or select TOP(1) Name from Worker I have 1,000,000 records thank's in advance ...

How to iterate over a date range in PL/SQL

I need to write a report that generates summary totals against a table with date ranges for each record. table data: option start_date end_date opt1 6/12/2009 6/19/2009 opt1 6/3/2009 6/13/2009 opt2 6/5/2009 6/6/2009 What I want out is basically this: date option count 6/1/2009 opt1 0 6/1/200...

In a StackOverflow clone, what relationship should a Comments table have to Questions and Answers?

In an application similar to StackOverflow that I am building, I am trying to decide what relationship my Questions, Answers and Comments tables should have. I could have Questions and Answers both be represented by a single table Posts. That would allow Comments to have a single foreign key to Posts. But if Questions and Answers are ...

XAML in Database - Getting Very Meta

How would you go about making an application that can edit it's own look and feel? Can tweak its own XAML files? then reload them. I'm thinking a notepad-like text editor, not a visual designer. All the event/code would be bound right after display from an "iron" scripting language. ...

How should you build your database from source control?

There has been some discussion on the SO community wiki about whether database objects should be version controlled. However, I haven't seen much discussion about the best-practices for creating a build-automation process for database objects. This has been a contentious point of discussion for my team - particularly since developers a...

Am I translating Ansi OUTER JOIN syntax correctly to older Sybase (*=) join syntax?

Assuming this is the correct Ansi SQL syntax for a left outer join: SELECT * FROM employee LEFT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID And this is the correct Ansi SQL syntax for a right outer join: SELECT * FROM employee RIGHT OUTER JOIN department ON employee.Departme...

LINQ Design and Prototyping

I'm about to start my first LINQ (to Entities) 'enabled' project, and it immediately strikes me how easy it is to draft SQL queries in SQL Server vs. writing and running code to check results. What do people usually do here? Prototype in T-SQL then implement in code, or use a tool, or what? ...

Identity column maximum value in SQLite DBs

I have a purely academic question about SQLite databases. I am using SQLite.net to use a database in my WinForm project, and as I was setting up a new table, I got to thinking about the maximum values of an ID column. I use the IDENTITY for my [ID] column, which according to SQLite.net DataType Mappings, is equivalent to DbType.Int64. ...

Database Refresh

How often do you refresh your development database from production database?Since there are many types of projects (targeting different domains) I would like to know how it is being done and at what intervals(days/months/years) it is being done ? thanks ...

Why is my Update command updating all of the fields that have the same ID?

Using the update command, I want to change the type_name for a specific entry in the database, but it is changing the type_name for all the entries with the same type_id. I need it to only change that individual entry's type_name, and not the type_name that is associated with all the entries with the same type_id. I have an update quer...

Cascade Triggers in SQLite

I've the following DB structure in SQLite: I want to create a trigger that whenever I delete a country all the related districts, municipalities and parishes are also deleted (like MySQL InnoDB), I've tried using SQLite triggers and came up with this: Districts: CREATE TRIGGER [delete_country] BEFORE DELETE ON [countries] FOR EACH R...

Data structure for storing serial port data in firmware

I am sending data from a linux application through serial port to an embedded device. In the current implementation a byte circular buffer is used in the firmware. (Nothing but an array with a read and write pointer) As the bytes come in, it is written to the circular bufffer. Now the PC application appears to be sending the data too f...

Why does this transport-level error occur?

After a breakdown on my virtual webhost, they finally restored the container, but now I randomly get the error when I try to execute queries. I can do a Select top 20000 from Orders But Select * from Orders (about 100k rows total) Receives the error in my management studio: A transport-level error has occurred when rece...