sql

Auto reconnect to MySql after connection lost

Hi, I have a c# application that uses a MySql database, the problem that after a period of inactivity (8 hours) or when connection to the server where database is host is lost, the connection to the database is closed and database queries cannot be executed. how can i enable the auto reconnect to the database. Best regards. ...

Check My Database Design / PHP/MySQL

Hello, I'm currently working on improving my database to make room for growth. As it stands, different users have different 'permissions' to areas of the website. Some users have permissions to multiple areas of the website. I'd like some feedback if I'm doing this in the most efficient way: tblUsers: usrID usrFirst ...

SQL Server 2005 loading data from an external server

Have a new project with the following setup and requirments:- My client has a MSSQL 2005 server (A) in their office. Their vendor has a MSSQL 2005 server (B) in another part of the world, which contains real-time transactional data. My client wants to load the data from (B) to (A) on a daily basis during non office hours. They have data...

How to find rows in one table that have no corresponding row in another table

I have a 1:1 relationship between two tables. I want to find all the rows in table A that don't have a corresponding row in table B. I use this query: SELECT id FROM tableA WHERE id NOT IN (SELECT id FROM tableB) ORDER BY id desc id is the primary key in both tables. Apart from primary key indices, I also ha...

Performance in PDO / PHP / MySQL: transaction versus direct execution

I am looping through a number of values (1 to 100 for example) and executing a prepared statement inside the loop. Is there and advantage to using a transaction - committing after the loop ends - compared to a direct execution inside the loop? The values are not dependant on each other so a transaction is not needed from that point of ...

SQL, How to query with multiple foreign keys in a table?

Hi there I have a projects table which has two foreign keys for users (user_id and winner_user_id), one for the owner of the project and one for the winner of the project. Something like +----------------+-------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Defaul...

Why is SQL Server deprecating SET ANSI_PADDING OFF?

According to MSDN BOL (Books Online) on SET ANSI_PADDING, In a future version of Microsoft SQL Server ANSI_PADDING will always be ON and any applications that explicitly set the option to OFF will produce an error. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. I h...

Which schema does this associative table belong to?

I was going over AdventureWorks2008 database and wanted to create a new table that associates a product to a sales person. There is a many-to-many relationship between those tables. The question is, Of two schemas, Sales and Production, does ProductSalesPerson table belong to? ProductSalesPerson doesn't neccessarily belong to either ...

Pictures in SQL DB

Hi, how big (binary(xy)) should I make my table column in SQL database if I want to store there pictures taken by camera - that means variable size up to.. I don't know.. 7MB? But if I should rather limit the size up to 2MB or something, I would. Whats your opinion? EDIT Or where else should I store them? I am building a web gallery us...

SQL SELECT from multiple tables

How can I get all products from customers1 and customers2 include their customer names? customer1 table cid name1 1 john 2 joe customer2 table cid name2 p1 sandy p2 linda product table pid cid pname 1 1 phone 2 2 pencil 3 p1 pen 4 p2 paper Result should be like this pid cid pname name1 name2 1 1 phone ...

How do I create a schema like .dbo in SQL Server [2005]

I am creating a database in SQL Server 2005 and cannot remember the "CREATE SCHEMA" statment, if that's it, to create a new schema similar to ".dbo". I did it last night, but I cannot remember how and cannot find the article. What I'm trying to accomplish is a database organization like that of the AdventureWorks database where the tab...

Find duplicate content using MySQL and PHP

Hello, I am facing a problem on developing my web app, here is the description: This webapp (still in alpha) is based on user generated content (usually short articles although their length can become quite large, about one quarter of screen), every user submits at least 10 of these articles, so the number should grow pretty fast. By na...

SQL Server ARITHABORT

I'm working with a client who has just upgraded from SQL 2000 to SQL 2008 and their view query times have gone up a lot. I had a look at the views and couldn't see much wrong with them. When I ran the view directly on the server, the times were OK. When I ran via Management Studio remotely, the time goes from 2secs to about 30secs. So,...

Parse out Non-Alpha Numeric characters from SQLCHAR object

I currently have a bunch of SQLCHAR objects from a database query. The query results are stored in a std::string and then binded to the individual SQLCHAR variables. Some of these variables need to be parsed in order to remove any non-alphanumeric characters. What is the best approach here? I have implemented a basic parsing of a std::s...

Cleaning up identical rows with SQL

How to clean a database from identical by a specific field rows so that only one copy of each set of identical rows is left there? I have a table: CREATE TABLE table1 (field1 varchar(255), field2 varchar(255)); I'd like to purge table1 of any unnecessary copies of rows, leaving a random row from each set of rows with the same fie...

Looking for HW double check on database design.

hey everyone... so i'm working on a database design class for university. I've got the question below and my attempt at the diagram here http://tinypic.com/view.php?pic=httchc&s=3.. would anyone mind taking a look and offering suggestions? thanks for the help!! QUESTION: Question 3 The following situation describes a company that ...

Table locked during inserts... website unusable (sql server 2008)

I have a background process that is constantly inserting into a table in real-time. It could be thousands of inserts an hour (with a few updates). This same table is used by the web application to get some data needed to display to the user. Currently whenever the background process runs its inserts/updates, the web app seems blocked a...

SQL query to get "vote score"

My votes table looks like this: id: integer vote: boolean voteable_id: integer voteable_type: string voter_id: integer voter_type: string The vote column determines whether the row represents an "up vote" (vote = true) or a "down vote" (vote = false). voteable_type is the class of the thing being voted on, voteable_id is the id of th...

Using illegal names in MySQL through SQLObject

How to use illegal names for MySQL with SQLObject? In pure SQL it is possible to use backquotes, say: SELECT `select from` FROM table1 WHERE 1; ...can be used to select the field called select from. Is it possible to tell SQLObject to utilize backquotes? ...

Best database for high write (10000+ inserts/hour), low read (10 reads/second)?

I'm developing a web app and currently using sql server 2008 for it. But, I am considering moving to another database (simpledb) for improved performance. I have a background process that inserts up to 10000 rows every hour into one specific table. That table is also read from to display data in the web application. When the background...