database

Does every table really need an auto-incrementing artificial primary key?

Almost every table in every database I've seen in my 7 years of development experience has an auto-incrementing primary key. Why is this? If I have a table of U.S. states where each state where each state must have a unique name, what's the use of an auto-incrementing primary key? Why not just use the state name as the primary key? Seems...

sql using aliases

I seem to be having some trouble grasping the concept of using AS to create an alias, and then using that alias later. Here is an example of a very simple query that I get an error when I run: SELECT IP, (SELECT server_ip as IP FROM table1 WHERE start_time BETWEEN @startdate AND @enddate Group By...

Unique sign in PHP Forum for my site

I am trying to have a forum using php in the site, but i want unique sign in, is there a platform that i could integrate and share DB. ...

Recommended way to store a book on iPhone?

I'm looking to store an entire book on an iPhone. I wanted to make the book searchable - it's a reference text. I'm also looking to break the book into chapters, or sections, etc. so that I can add a Table of Contents that the user can browse, and click to go straight to a particular chapter. At first I thought about using SQLite to ...

Document vs key-value databases?

Possible Duplicate: Difference between Document-based and Key/Value-based databases? What are the pros and cons of document (mongodb/couchdb) and key-value (riak/redis) databases? Aren't document databases more powerful than simple key-value databases? Why would I use for example riak over couchdb that seems more powerful? ...

Calculate database performance on overload.

I don't know if this is the right place for this question, but here it comes: I have a db function that I tested and can handle about 3000 requests/minute. The problem is that this calculation just gives me the optimal performance of the function (~18ms/request). How do I calculate the performance when the requests are twice, triple or ...

Modelling a price matrix table in MySQL

Hello good people of stackoverflow, I am trying to create an ecommerce product that takes orders for print jobs. I would like to create tables such as the ones here on solopress for example http://www.solopress.com/leaflet-printing/leaflets.html. I am just struggling a little with the logical steps of modelling this in a database. Firs...

query on finding youngest person

Hi, I am writing a query on Mysql . I have to find the youngest customer and in my database , I have 2 persons with same dob. I am doing it in a way that first it checks all the conditions and then order by dob desc, limit 1. It gives me only 1 result. If I set the limit 2, I get the second person but setting limit according to database...

Simple SQL DAL for 4-5 queries

I have to gather data from a sql database to populate a ning map i am creating. I only need data from one table in the database. The table has company data in it, name country state, email, website, etc. What is the best way to do this? I am doing my bing map using .net so i was thinking of just gathering all my data in code behind i...

Android handle app updates and database changes

I have basically finished developing an android app that makes use of SQLite databases that I copy to the user data area on the device eg /data/data/com.company.app/databases/users.db I am unsure how the marketplace app update procedure takes place and am also unsure as to how I could test it. I currently check whether the database exi...

A query to determine if a column is computed

Possible Duplicate: Get List of Computed Columns in Database Table (SQL Server) In SQL Server 2008 is there a stored procedure I can run or view I can query which shows whether a column is a computed column? I've tried querying information_schema.columns but it doesn't seem to provide this information. ...

Should I use sessions for "LOGINS" on my site?

I have a classifieds website, where anyone (no need for login currently) can post a classified. It is PHP based. The procedure for posting is currently like this: click on "New Classified" ---> fill in a form of all information and hit "View classified before publishing it" ---> the form submits to a "verify classifieds" page, where...

exporing data and schema of databse

1)does database backup exports only data or schema as well? 2)i have one PC running DB2 database server1 and having a database XYZ,Now i want to create replica of this database on another pc running db2 datbase. 3)I dont want to do this without using affecting db server1, i dont want it to stop or hang 4)can i use db2 BACKUP DATABASE t...

How do I set up an index on a pair of columns so that the values are tied together?

I have a table with id, external_id and country_code columns. I have two rules which I want the database to impose: Each External ID can only appear once per country code Each ID can only appear with at most one non-null External ID, and vice versa. The first rule is easy enough - I add a unique multi-column index to external_id and...

Sync large local DB with server DB (MySQL)

I need to weekly sync a large (3GB+ / 40+ tables) local MySQL database to a server database. The two databases are exactly the same. The local DB is constantly updated and every week or so the server DB need to be updated with the local data. You can call it 'mirrored DB' or 'master/master' but I'm not sure if this is correct. Right now...

BIRT: Join too slow

I have a large table in my DB from which I need a couple of rows for a report. The JOIN turned out to be too slow. So my solution was to read the values into a HashMap and simply join them manually in each row of the report. How can I fill the map in the open script of a scripted data source? My current solution was to pass the URL/use...

Association between two entries in SQL table

Hi all, Imagine you have a database table that stores a list of people. You want to establish a relationship between peoples, i.e., person I is friend with person J. I suppose in this case, one needs a second table to store people associations. This table would contain two fields (person1, person2) and each entry corresponds to a one-t...

PostgreSql + Typecast of Boolean into Character Type

Here, I am unable to convert boolean value into character in postgre sql query. SELECT *FROM ltl_class_nmfc_aliases WHERE ltl_class_nmfc_aliases.id NOT IN(SELECT ltl_class_nmfc_aliases_id FROM commodities_shippeds WHERE commodities_shipped_obj_type LIKE 'ClientOffice') OR ltl_class_id IS NULL AND lower(commodity_description_alias) ...

How to optimize number of database connections?

Hello everybody! We have a Java (Spring) web application with Tomcat servlet container. We have a something like blog. But the blog must load its posts dynamically with Ajax. The client's ajax script checks for new posts every second. I.e. Ajax must ask the server for new posts every second and it will be very heavy for database. But...

Database design - primary key naming conventions

Hi, I am interested to know what people think about (AND WHY) the following 3 different conventions for naming database table primary keys in MySQL? -Example 1- Table name: User, Primary key column name: user_id -Example 2- Table name: User, Primary key column name: id -Example 3- Table name: User, Primary key column name: pk_us...