database

Preventing bad data input

Is it good practice to delegate data validation entirely to the database engine constraints? Validating data from the application doesn't prevent invalid insertion from another software (possibly written in another language by another team). Using database constraints you reduce the points where you need to worry about invalid input dat...

In sql server 2005, how do I change the "schema" of a table without losing any data?

I have a table that got into the "db_owner" schema, and I need it in the "dbo" schema. Is there a script or command to run to switch it over? ...

SQL Server sys.databases log_reuse_wait question

I was investigating the rapid growth of a SQL Server 2005 transaction log when I found that transaction logs will only truncate correctly - if the sys.databases "log_reuse_wait" column is set to 0 - meaning that nothing is keeping the transaction log from reusing existing space. One day when I was intending to backup/truncate a log ...

Getting PHP to read .doc files on Linux

I'm trying to read a .doc file into a database so that I can index it's contents. Is there an easy way for PHP on Linux to read .doc files? Failing that is it possible to convert .doc files to rtf, pdf or some other 'open' format that is easy to read? Note, I am not interested in .docx files. ...

Modularity in database design

Is there a good book/article discussing the modularity in database design? By modularity I mean the keeping the tables belong to individual modules separte. Do not allow join between tables of different modules. And the kind of issues discussed in the question http://stackoverflow.com/questions/69128/saas-database-design-multiple-databas...

How do I best convert a string representation into a DbType?

Suppose I have a string 'nvarchar(50)', which is for example the T-SQL string segment used in creating a table of that type. How do I best convert that to an enum representation of System.Data.DbType? Could it handle the many different possible ways of writing the type in T-SQL, such as: [nvarchar](50) nvarchar 50 @Jorge Table: Yes,...

What is the best way to add users to multiple groups in a database?

In an application where users can belong to multiple groups, I'm currently storing their groups in a column called groups as a binary. Every four bytes is a 32 bit integer which is the GroupID. However, this means that to enumerate all the users in a group I have to programatically select all users, and manually find out if they contain ...

When people talk about scaling a website with 'shards', what do they mean?

I have heard the 'shard' technique mentioned several times with regard to solving scaling problems for large websites. What is this 'shard' technique and why is it so good? ...

How can I delete duplicate rows in a table

I have a table with say 3 columns. There's no primary key so there can be duplicate rows. I need to just keep one and delete the others. Any idea how to do this is Sql Server? ...

Is there a simple tool to convert mysql to postgresql syntax?

I've tried the tools listed here, some with more success than others, but none gave me valid postgres syntax I could use (tinyint errors etc.) ...

Add column, with default value, to existing table in SQL Server

How do you add a column, with a default value, to an existing table in SQL Server 2000/2005? ...

MySQL slow query log - how slow is slow?

What do you find is the optimal setting for mysql slow query log parameter, and why? ...

Reverse Engineering for Database Diagramming in Visio with SQL Server 2008

I need to reverse engineer a Microsoft SQL Server 2008 in order to create a Microsoft Visio 2007 Database Model Diagram. So I choose Reverse Engineer from the Database menu to connect to the DB. I configured the Microsoft SQL Server Visio driver so that is uses SQL Server Native Client 10.0 as the ODBC driver. Afterwards I created a Use...

Separating user table from people table in a relational database

I've done many web apps where the first thing you do is make a user table with usernames, passwords, names, e-mails and all of the other usual flotsam. My current project presents a situation where non-users records need to function similarly to users, but do not need to the ability to be a first order user. Is it reasonable to creat...

versioned rails db and differ

I'm wondering if there's an integrated solution to have a database with versioned records supported by rails (ala version_fu ar_versioned) and a differ thanks! ...

Do you generate code? If so, what do you use and what do you generate?

I've used MyGeneration, and I love it for generating code that uses Data Access Applicaiton Blocks from Microsoft for my Data Access Layer, and keeping my database concepts in sync with the domain I am modeling. Although, it took a steeper than expected learning curve one weekend to make it productive. I'm wondering what others are doi...

Is there a .NET/C# wrapper for SQLite?

I'd sort of like to use SQLite from within C#.Net, but I can't seem to find an appropriate library. Is there one? An official one? Are there other ways to use SQLite than with a wrapper? ...

How can I maintain consistent DB schema accross 18 databases (sql server)?

We have 18 databases that should have identical schemas, but don't. In certain scenarios, a table was added to one, but not the rest. Or, certain stored procedures were required in a handful of databases, but not the others. Or, our DBA forgot to run a script to add views on all of the databases. What is the best way to keep database...

Fetch one row per account id from list

I have a table with game scores, allowing multiple rows per account id: scores (id, score, accountid). I want a list of the top 10 scorer ids and their scores. Can you provide an sql statement to select the top 10 scores, but only one score per account id? Thanks! ...

SQLite / Firebird embedded for numeric data

I have an experiment streaming up 1Mb/s of numeric data which needs to be stored for later processing. It seems as easy to write directly into a database as to a CSV file and I would then have the ability to easily retrieve subsets or ranges. I have experience of sqlite2 (when it only had text fields) and it seemed pretty much as fast ...