database

Database: Best performance way to query geo location data ???

I have a MySQL database. I store homes in the database and perform literally just 1 query against the database, but I need this query to be performed super fast, and that's to return all homes within a square box geo latitude & longitude. SELECT * FROM homes WHERE geolat BETWEEN ??? AND ??? AND geolng BETWEEN ??? AND ??? How is the b...

Database column naming question

Let's suppose there is a table called AIRPORT and I have to choose between two naming conventions: to name attributes like AP_CODE, AP_NAME and so on or to name them just like CODE, NAME The question is whether it is more efficient to follow the first way or to use synonym (i.e. AP) and reference attributes like AP.CODE? Thanks in adva...

Refresh Database On iPhone

I am trying to push an updated version of my sqlite db to my device and so far have not figured out a way to do it other than renaming it each time (painful). The stale (cached?) copy remains permanently on the device. I understand how to get an updated version into the simulator by clearing the /applications folder, but this does not ...

How can I prevent inner SELECT from returning NULL?

How can I prevent inner SELECT from returning NULL (when matches no rows) and force query to fail. INSERT INTO tt (t1_id, t2_id) VALUES ( (SELECT id FROM t1 WHERE ...), (SELECT id FROM t2 WHERE ...) ); Side question: is there better way form this query (t1_id, t2_id are foreign keys, but might be NULL) ? ...

DB Tables naming conventions

Hello, I am trying to find out what are the popular naming conventions for DB tables. Therefor I have 2 questions: Lets say you have a table with persons in it. Each row is a person. How would you call the table - 'PERSONS' or 'PERSON'? Now lets say there is another table named 'PERMISSIONS' and you are creating a new table which is m...

MySQL performance issue - lots and lots of ORing

The Facebook API has a call $facebook->api_client->friends_getAppUsers(); and that returns the friend ids of a user who is using the app. Now say I want to select from my db table all the rows that match all those friend ids. The only way I can think of doing it would be SELECT * FROM my_table WHERE uid IN(friend1, friend2, friend3, f...

database sharding strategy

For an online marketplace product under construction, I have a situation which requires implementing a database sharding solution. I am new to sharding and after reading the posts in this forum I feel a directory based sharding strategy using business entities will be suitable. But I am still not clear about the denormalization and data ...

Need an advice regarding accessing the database

Suppose I have a Comment class having properties and their methods like public Comment GetComment(Guid id) And public static List<Comment> GetComments() public static List<Comment> GetCommentsByAuthor(Author id) Now, What I usually do is write the database logic for each of the above methods . That said, Now I am seeing BlogEngine...

I need an advice about NoSQL/MongoDb and data/models structure

Hi everyone, Recently I'm exploring NoSQL Databases. I need an advice about how to store data in the most optimal and efficient way for a given problem. I'm targeting MongoDB, now. However it should be the same with CouchDB. Let's say we have these 3 Models: Story: id title User: id name Vote: id story_id user_id I want ...

How can I see the data of a SQL server database in c#, and where it's store?

Hello, I have a program written in c# visual studio 2008 with SQL server 2005 (.mdf) database. Here is part of the code: ... SqlCommandBuilder cb; cb = new SqlCommandBuilder(dataAdapter); String[] dataList =new String [8]; ... DataTable resultTable = new DataTable(); ...

Best Approach to handle Data Concurrency In 3-Tier Application

Hi, What is the best approach to handle Data Concurrency issues in a 3 layered Application (WCF + LinqToSql or EF) with detached entities or DTOs ? Thanks. ...

Why didn't see 10 records in database ?

I use JMeter to test my web application. and my test case is to add a record in database. and then I set the "number of thread user" to 20, it means that it will simulate 20 users work at the same time. and then I run the test case. But finally i found the system didn't create 20 records in database, but instead just create 13 records in...

What is meant by 'House Keeping' in context of a database ?

One of my clients has mentioned the term 'Database House Keeping' in his tender specs. I am not sure about the term, please help. ...

How do I Create a Comma-Separated List using a SQL Query?

I have 3 tables called: Applications (id, name) Resources (id, name) ApplicationsResources (id, app_id, resource_id) I want to show on a GUI a table of all resource names. In one cell in each row I would like to list out all of the applications (comma separated) of that resource. So the question is, what is the best way to do this ...

Using Flyweight Pattern in database-driven application

Can anyone please give me any example of situation in a database-driven application where I should use Flyweight pattern? How can I know that, I should use flyweight pattern at a point in my application? I have learned flyweight pattern. But not able to understand an appropriate place in my database-driven business applications to use ...

Rails data modeling question

I am creating a simple todo app where I have 2 types of tasks. 1) regular tasks - These have a due date 2) recurring tasks -These are poped up as reminders on specified date. They can be created either as weekly or monthly reminders. If created for a week, it will be poped up on each week (on a specified date on the week). Likewise for...

How is Twitter's MySQL database architecture designed? Try your best.

No one knows. And even if you work at Twitter, you probably won't let us know the secret. So, let us all post our theories on how this communication tool database is designed! It definitely can't follow the standard replication architecture, right? It's got to do some sharding, partitioning, etc, etc. Let me know what you think! ...

Testing framework for data access tier

Is there any testing framework for Data access tier? I'm using mysql DB. ...

Creating/dropping MySQL databases with integer names

How to create/drop databases which have integers as their names, from the command line? Using GUI clients, I can create/drop them fine. However, 'create/drop database' does not seem to work because the names are integers. Using GUI clients is fine with me, but curious to know: are there any workarounds to do this in command line? Not...

Set Current Database in MySQL Script

I have a script file for MySQL that needs to be run on about 30 databases. Here's a snippet: ALTER TABLE <whatever_database>.`tblusers` ADD COLUMN `availability` ... ALTER TABLE <whatever_database>.`tblusers` ADD COLUMN `reliability` INTEGER ... There are many more lines in this script and I'd like to automate it in a loop of current...