database

How to get count of another table in a left join

I have multiple tables post id Name 1 post-name1 2 post-name2 user id username 1 user1 2 user2 post_user post_id user_id 1 1 2 1 post_comments post_id comment_id 1 1 1 2 1 3 I am using a query like this: SELECT post.id, post....

Local-to-remote port forwarding using Ruby/Net::SSH for remote db connection

Hello, I'm accessing a remote database using a local-to-remote port forwarding from my windows box. It works like a charm using putty for port forwarding but it fails when I try to forward using Ruby/Net::SSH. Here is my code snippet: require 'rubygems' require 'net/ssh' Net::SSH.start(remote_host, user_name, :password => password) do...

Regarding Database data deletion from tables in mysql

Hi All, I'm new to mysql. My Requirement is I have a database "sample" and there are 20 tables in it with some sample data. I want to remove all the data from all tables of that database without deleting tables or recreating them So please help me with a solutions. Regards Chandu. ...

Android - database disk image is malformed

Hi In my android app I am getting "database disk image is malformed" What are the reasons for getting this error? not closed db? multiple threads accessing the db? or android just got corrupted? Thanks ======================================================================================== android.database.sqlite.SQLiteDatabaseCorr...

Different types of Id when exposing DTO over WCF

Lets say we have a simple DTO with properties Id, Name. If this DTO comes from database through some data layer, Id should be of type int. If this DTO comes from Active Directory, through some data layer, Id should be of type Guid. What would be the best way to implement this? Thanks in advance! ...

Plotting a word-cloud by date for a twitter search result? (using R)

Hello all, I wish to search twitter for a word (let's say #google), and then be able to generate a tag cloud of the words used in twitts, but according to dates (for example, having a moving window of an hour, that moves by 10 minutes each time, and shows me how different words gotten more often used throughout the day). I would apprec...

where to store information like gender and year of birth?

i have users and i need them to specify a gender (male, female) and year of birth (1930, 1931...1999, 2000). i wonder where i should store these values: in the database? in php file? if i store them in the database i have to manually create all entries first. but a good thing is that the user table will have constraints so the gende...

Prevent duplicate rows with all non-unique columns (only with MySQL)?

How do I prevent a duplicate row from being created in a table with two columns, neither of which are unique? And can this be done using MySQL only, or does it require checks with my PHP script? Here is the CREATE query for the table in question (two other tables exist, users and roles): CREATE TABLE users_roles ( user_id INT(100) NOT ...

Storing Sessions in a DB in PHP - keep getting mysql error

Hi guys, I want to store all my sessions in a DB and have read up on this and implemented the following class: <?php /** * This class handles users sessions and stores the session in the DB rather than in a file. This way stops any * shared host security problems that could potentially happen. */ class sessionHandler { /** ...

Data Modeling of Entity with Attributes

I'm storing some very basic information "data sources" coming into my application. These data sources can be in the form of a document (e.g. PDF, etc.), audio (e.g. MP3, etc.) or video (e.g. AVI, etc.). Say, for example, I am only interested in the filename of the data source. Thus, I have the following table: DataSource Id (PK) Filenam...

How do you hook a C++ compiled dll function to a sql database?

I want to do something like: lastName SIMILARTO(lastName, 'Schwarseneger', 2) where lastName is the field in the database, 'Schwarseneger' is the value that lastName field is being compared to and 2 is the maximum number of characters (edit distance) that can differ between the lastName field, and the entered value. I can implement the...

How to modernize an enormous legacy database?

I have a question, just looking for suggestions here. So, my application is 'modernizing' a desktop application by converting it to the web, with an ICEFaces UI and server side written in Java. However, they are keeping around the same Oracle database, which at current count has about 700-900 tables and probably a billion total records...

Stock management of assemblies and its sub parts (relationships)

I have to track the stock of individual parts and kits (assemblies) and can't find a satisfactory way of doing this. Sample bogus and hyper simplified database: Table prod: prodID 1 prodName Flux capacitor prodCost 900 prodPrice 1350 (900*1.5) prodStock 3 - prodID 2 prodName Mr Fusion prodCost 300 prodPrice 600 (300*2) prodStock 2 - ...

How to "upgrade" the database in real world?

My company have develop a web application using php + mysql. The system can display a product's original price and discount price to the user. If you haven't logined, you get the original price, if you loginned , you get the discount price. It is pretty easy to understand. But my company want more features in the system, it want to disp...

Why use your application-level cache if database already provides caching?

Modern database provide caching support. Most of the ORM frameworks cache retrieved data too. Why this duplication is necessary? ...

Real World Experience of db4o and/or Eloquera Database

I am evaluating two object databases, db4o (http://www.db4o.com) and Eloquera Database (http://eloquera.com) for a coming project. I have to choose one. My basic requirement is scalability, multi user support and easy type evolution for RAD. Please share your real world experience. If you have both, can you compare these two? Which do...

Application/Script for checking "unseriousness" possible?

I have a classifieds website where users may sell/buy just about anything... My issue which costs the company alot of money, time etc is that ALL classifieds must be reviewed by a physical person (employee) before beeing posted on the website. So when you create a new classified enty, you get the message like "Your ad will be reviewed ...

how to get all code of stored procedure in c#.net window and create textFile of storedprocedure in C#.net window Application

I Want get All Code of stored procedure from database and convert that procedure in textfile and save that textfile in particular path in c#.net window application. ...

In-Proc DB supporting sprocs

Is there an in process database, like SQLite or Sql Server Compact Edition, that supports stored procedures? ...

Recursive only 2 level records using common sql

I have an Employee table, it's a self-referencing table, with managerId refers to primary key empID. I want to find 2 level records by a given empId. For example: if given empId=5, if empId=5 has children records, display them, as well as the children in children records. The database is SQL Server 2005. update: I wanna a full project...