database

Type-ing quesion

Hey everyone, I have a few tables in my database and they all contain a different inherited type of a DataRow. In addition I have a class that is supposed to handle some things in my DataGrid (My database Tables are connected to DataGrids). In order to do that, one of the methods in this DataGrid handler has to cast the rows to the exa...

How to create a trigger to record changes for Insert,Update,Delete for multiple tables.

I have two tables in my Database.This can increase later on.I want to add another table Audit to track changes to the existing two tables.I want to track any change done to any of these table AUdit Table structure is ID Table_Name Field_Name Old_Value New_Value Modified_By Date_of_Modification SO now I want to have one trigger for bot...

Using Java, I upload an image to postgres DB size is 4000. But when I download it, the size is 8000.

Here is the latest code. I wanted to try something different but I am still getting the same results. I am using postgres DB and I created a column called file with a data type bytea. The image does get uploaded to the DB (I can see it in there when I view the table's data). I tried it with several images. The size appears to be correc...

How to create production database sample for testing?

Is there a tool (for PosgreSQL, ideally), which can make a small, but consistent sample of a big database? The this is we need a testing database, but we don't want to fully copy the production one. First, because it is too big and second, the nature of testing implies that the testing database will be recreated several times in the pro...

How to fetch data from oracle database in hourly basis

Hi all, i have one table in my database say mytable, which contents request coming from other source. There is one column in this table as Time, which stores date and time(e.g. 2010/07/10 01:21:43) when request was received. Now i want to fetch the data from this table on hourly basis for each day. Means i want count of requests database...

Wordpress blog : Import content

Hi, I am running a website using PHP/MySQL. Now I want to allow Blogs using wordpress in my website so I can use Google Adsense along with blog content. I have installed Wordpress on my site, using tools provided by host service provider. Now is there anyway I can import selective-content from MySQL database to these wordpress blogs? ...

creating a database for a photo gallery with comments

I am creating a social network and want to have a similar photo gallery to that of facebook. Im guessing I need to use AJAX but I would like to have a comments section for each photo. I was just wondering what the best way would be to design a database around this. Do I just make a table of comments? Would I run into performance issu...

Is there a legitimate reason for using so many varchar fields? (MS SQL DB)

I'm working on data migration from an old IBM Universe-based system to a new enterprise-level data-information management system, and learning about database design in the process. I took a look at the back-end database structure of the new system (it's a MS SQL DB, with about 100 tables), and find some things pretty odd. But I don't k...

How do you store variables fields ?

Hi, I've a database where I've comments, votes, galleries, images, etc... For examples, galleries and images can be commented using the same form, then I'll store it in a single table, comment. I'm wondering how would store this type information in the comment table? Using a ENUM type, a foreign key against a type table, hardcoded on i...

How and when to deal with database that is down ?

My problem is that I have to deal somehow with cases when database is down in my MVC application. So, should I like try{} catch{} to open connection in every controller? Or what is the best practice? Note: For sample database access is isolated in few "manager" classes that work repository kind of way. ...

Does anyone know of a tutorial for datamapper + sqlite3 with ruby?

I'm a newbie to programming & ruby (as well as datamapper & sqlite). I'm trying to figure out how to use all three but can't find any tutorials for beginners. Please let me know of tutorials or books. Thanks. ...

How to Update Data Source in C#

I am working on a Windows Form-Based application in Visual Studio 2008 using C# with an Access database as a back end. I added the Access database into the project by going to Data->Add New Data Source and I am able to retrieve data from the database's custom-made DataSet perfectly. My next goal is to save new data back into the Access ...

Undefined method has_attached_file after Paperclip installation?

Not sure if I've done everything right here. I added the Paperclip gem to my Gemfile and did bundle install. I followed along with the readme instructions on Paperclips Github page. I wasn't sure if I needed to install ImageMagick. But, I found a script on Github for installation on Snow Leopard, so I ran: rails plugin install http:/...

Weighted average calculation in MySQL?

I am currently using the following query to get some numbers: SELECT gid, count(gid), (SELECT cou FROM size WHERE gid = infor.gid) FROM infor WHERE id==4325 GROUP BY gid; The output I am getting at my current stage is the following: +----------+-----------------+---------------------------------------------------------------...

When and How Does the Database Slow Down a Site?

I have read a book by O'Reilly that states that 70-80% of the performance of a site can be optimized via the front-end. That may mean that database queries may account to less than 20 or 30% of a site's performance. However, I have seen huge websites like Facebook and Twitter dedicate so much time to optimizing queries (via query caching...

Database Design - Column In One Table References Two Tables

Here is an example of what I have (take Stack Overflow). I have 2 tables, Questions and Answers. I also have a Comments table. The Comments table will reference both Questions and Answers. How should I set up the database? Have 2 columns in Comments, a QuestionId and AnswerId. Have one table for both Questions and Answers? Have ...

SQL Server Express alternatives beyond 2GB limit

In our project (which is fully developed using .NET), we use a medium sized database about 2 GB in size. Currently we are using SQL Express edition; How do the alternates for SQL Server Express perform? I am mainly considering MySQL and PostgreSQL. (Windows 7 x86, x64) Is there any compelling advantage to using MySQL or PostgreSQL? W...

How to tell if sqlite database file is valid or not

In the code below, pathToNonDatabase is the path to a simple text file, not a real sqlite database. I was hoping for sqlite3_open to detect that, but it doesn't (db is not NULL, and result is SQLITE_OK). So, how to detect that a file is not a valid sqlite database? sqlite3 *db = NULL; int result = sqlite3_open(pathToNonDatabase, &db);...

Delete duplicated rows from database

I need to delete duplicated rows from database. Can i do it with simple sql query? If not, please, show me some quick algorythm to do it. Example: id| field_one | field_two | 1 | 0000000 | 11111111 | 2 | 2222222 | 33333333 | 3 | 2222222 | 33333333 | 4 | 4444444 | 55555555 | I need to delete row with id 2 (or 3, no matter,...

Populate DataTable with records from database?

This is my GET Method to get my data from my DataTable Private Function GetData() As PagedDataSource ' Declarations Dim dt As New DataTable Dim dr As DataRow Dim pg As New PagedDataSource ' Add some columns dt.Columns.Add("Column1") dt.Columns.Add("Column2") ' Add some test data For i As Integer = 0 To 10 dr = dt.NewRo...