database

Best practices for extending third party databases?

I have a situation where our developers extended a Third party database (MS SQL) by adding tables, views, stored procedures, and functions. Recently when the vender issued updates to the database they dropped all of our custom objects. The question now is what are some best practices that will allow us to extend the third party database...

postgresql duplicate table names best practice

My company has a handful of apps that we deploy in the websites we build. Recently a very old app needed to be included along side a newer app and there was a conflict w/ a duplicate table name needed to be used by both apps. We are now in the process of updating an old app and there will be some DB updates. I'm curious what people ...

Using a user-defined type as a primary key

Suppose I have a system where I have metadata such as: table: ====== key name address ... Then suppose I have a user-defined type described as so: datasource datasource-key A) are there systems where it's possible to have keys based on user-defined types? B) if so, how do you decompose the keys into a form sui...

What are your best practices for ensuring the correctness of the reports from SQL?

Part of my work involves creating reports and data from SQL Server to be used as information for decision. The majority of the data is aggregated, like inventory, sales and costs totals from departments, and other dimensions. When I am creating the reports, and more specifically, I am developing the SELECTs to extract the aggregated dat...

Moving information between databases

I'm on Postgres, and have two databases on the same machine, and I'd like to move some data from database Source to database Dest. Database Source: Table User has a primary key Table Comments has a primary key Table UserComments is a join table with two foreign keys for User and Comments Dest looks just like Source in structure, but a...

What are the pros and cons of storing files in a database?

Hi, I'm writing a php application and was wondering if it's a bad idea to store complete files in the database. Files should be around 100-200kb mostly text files (txt, doc, docx and so on) or small image files. Or is it just a plain wrong idea? ...

Can not delete row from MySQL

Howdy all, I've got a table, which won't delete a row. Specifically, when I try to delete any row with a GEO_SHAPE_ID over 150000000 it simply does not disappear from the DB. I have tried: SQLyog to erase it. DELETE FROM TABLE WHERE GEO_SHAPE_ID = 150000042 (0 rows affected). UNLOCK TABLES then 2. As far as I am aware, bigint is a ...

Relational MySQL - fetched properties?

I'm currently using the following PHP code: // Get all subordinates $subords = array(); $supervisorID = $this->session->userdata('supervisor_id'); $result = $this->db->query(sprintf("SELECT * FROM users WHERE supervisor_id=%d AND id!=%d",$supervisorID, $supervisorID)); $user_list_query = 'user_id='.$supervisorID; ...

how to store data crawled from website

I want to crawl a website and store the content on my computer for later analysis. However my OS file system has a limit on the number of sub directories, meaning storing the original folder structure is not going to work. Suggestions? Map the URL to some filename so can store flatly? Or just shove it in a database like sqlite to avoi...

Planning a programming project by example (C# or C++)

I am in the last year of undergraduate degree and i am stumped by the lack of example in c++ and c# large project in my university. All the mini project and assignment are based on text based database, which is so inefficient, and console display and command, which is frustrating. I want to develop a complete prototype of corporate soft...

Does iBatis enforce a primary key on my table?

Hi guys, I'm working on a legacy project. The database is poorly designed. I want to change the DB layer now. The first think go through my mind is hibernate, but I hibernate need a primary key on my table. In fact some of my table does not have primary key. So I did a google search and I find iBatis, it's sounds very good with it. But ...

In Python, if I have a unix timestamp, how do I insert that into a MySQL datetime field?

I am using Python MySQLDB, and I want to insert this into DATETIME field in Mysql . How do I do that with cursor.execute? ...

How do I do this query in MySQL? (datetime)

Suppose I have a datetime column in MySQL. How do I select all that have a datetime within 2500 seconds of the current datetime? SELECT ALL where current_datetime - that_datetime < 2500 ... ...

What is the most efficient way to store a mapping "key -> event stream"?

Suppose there are ~10,000's of keys, where each key corresponds to a stream of events. I'd like to support the following operations: push(key, timestamp, event) - pushes event to the event queue for key, marked with the given timestamp. It is guaranteed that event timestamps for a particular key are pushed in sorted or almost sorted or...

Printing ERD from SchemaSpy output

We have quite a large database schema and our business analysts would print it and take it to meetings. Is there any way to get schema spy to print an ERD to 1 A3 page? ...

Store and retrieve images from file system instead of database

Hi I need a place to store images. My first thought was to use the database, but many seems to recommend using the filesystem. This seems to fit my case, but how do I implement it? The filenames need to be unique, how to do that. Should I use a guid? How to retrieve the files, should I go directly to the database using the filename, m...

set up way of getting mysite.$domain

Hi I have several domains, only one website and one databse table for each domain. example: wbesite.us - data from USA goes to database table main_usa wbesite.co.uk - data form UK goes to database table main_uk Only have one database with name of the website. Having only one website structured, and having variables like $sql="select...

Storing SQL Queries within a Configuration file?

Hello y'all, A general question on what everyone's opinion is on storing SQL queries within a configuration file? Is this just another bike shed? Cheers, Ben ...

How to relate keywords to records - Many to Many

Hi All, I am looking for suggestions on database design for a sample jobs listing application. I have many jobs that I would like to associate various keywords with. Each job can have multiple keywords. I would like to store the keywords in a seperate table instead of in a field within the Job table so as to avoid mispellings in keyword...

help finding a hosing company with unixODBC and FreeTDS support

I need to find a hosting company that provides a LAMP stack, the P being PHP. Finding that is pretty easy, but I have a further requirement of unixODBC and FreeTDS or some equilant. The project will require a remote connection to a Microsoft SQL 2005 database. Most of the project will use a local MySQL database but it also requires d...