database

Django: Ordering objects by their children's attributes

Consider the models: class Author(models.Model): name = models.CharField(max_length=200, unique=True) class Book(models.Model): pub_date = models.DateTimeField() author = models.ForeignKey(Author) Now suppose I want to order all the books by, say, their pub_date. I would use order_by('pub_date'). But what if I want a list of all a...

what the difrent between primary..unique..foreign key, index

hi What is the difference between primary, unique and foreign key constraints, and indexes? I work on Oracle 10g and Sql Server 2008 thanks in advance ...

Database Design question

Hello everyone! I have a Firebird database, which let's say has Tables A and B which look like this: TableA TableB's Id | SomeNumber | OtherNumber | ComputedByField | OtherIntField 1 5 200 SomeNumber*OtherNumber 10 1 2 70 ... ...

does ordering by lot of columns hit the performance badly?

I just ran into a SQL query with about 5 different columns in the ORDER statement, is it a good practice and how does it play with performance? ...

Booking system dates in database

I need some help with the following: I am setting up a booking system (kind of hotel booking) and I have inserted a check in date and a check out date into database, how do I go to check if a room is already booked? I have no clue how to manage the already booked days in the database. Is there anyone who can give me a clue how this wor...

Question on locking and transactions on MyISAM table

Hello, I have a counter field in a myisam table. To update the counter value in a multitasking environment (web server, concurrent queries from PHP) I need to lock the record for update. So I do it like this: START TRANSACTION; SELECT Counter FROM mytable ... FOR UPDATE; UPDATE Counter value or INSERT INTO mytable; // let's make s...

Exclude Statement in SQL

Hello StackOverflow Community, I had a quick question on how to exclude data from an SQL database using an SQL statement. My situation is I have a user login to their profile page where they will be able to friend people. I want to display all users except themselves that are found in the SQL database. Thanks for all the answers! Roha...

What OR-mappers allow one-to-many AND One-to-one relationship between the same tables?

Hi, I'm currently looking for an OR-mapper to use for a side project I'm about to start. Since we're using an inhouse developed OR-mapper at work I don't really know much about how other mappers work (and have a pretty incomplete picture of which exist). After some research it seems that NHibernate, Linq-to-SQL and Entity Framework are ...

How to protect a database?

There is a website with a server database. I'm building a desktop application which uses data from one of the tables. Hacker can just take password from assembly. How can I protect the database? ...

How can I optimize this SQL query to get rid of the filesort and temp table?

Here's the query: SELECT count(id) AS count FROM `numbers` GROUP BY MONTH(created_at), YEAR(created_at) ORDER BY YEAR(created_at), MONTH(created_at) That query throws a 'Using temporary' and 'Using filesort' when doing EXPLAIN. Ultimately what I'm doing is looking at a table of user-submitted tracking numbers and co...

What kind of database would be best suited to maintaining a relatively large list of items with a counter for each item that is updated often in real time?

Let's pretend it's for word frequency counts in a web crawler. Is relational the way to go (I'm imagining a simple two-column table) or is there a NoSQL option better suited to this task? When I say better, I mean more conceptually suited to the task. I'm not really concerned with scalability, just simplicity and an obvious conceptual m...

Is there more beautiful database drawing software than visio?

Hello, I want to know if you know other beautiful database drawing software other than visio. Because i think visio is not delegant enough. So Can you give me some advice? Thanks a lot. ...

How to do a lot of database queries with less performance?

Hi guys, I have an auction site, not like ebay (as the most think). Now my problem is follow: On the startpage are a lot of auctions displayed (ASP.NET). All Auction (let's say min. 10, max 50) have a timer. Now I must have a look nearly every second for each auction (filter is not started and not ended) if the timer is reseted (what h...

Asp.net web application with MySQL

I see a lot of asp.net projects coupled with mssql2005 and mssql2008. Most of them don’t use MySQL for some reason.This is even true when an ORM like nhibernate is being used. Is this a pattern only to me or are there quite a lot of asp.net projects with MySQL as the db? If this is true, what might be the reason for not choosing M...

Drupal module to edit regular db tables

I have a few custom tables in my Drupal database that were created manually. Is there some Drupal module to allow viewing and editing records in custom tables? Tables are simple, no joins used. Or it's best to build some grid/record interfaces manually in custom module? ...

How do I change the permissions that MySQL uses to create database directories and files?

I have a self-installed MySQL service running on my OS X Snow Leopard machine, compiled using the automated installer from mysql.com. The problem I'm having is that I want to sync my database files, from the "data" directory, using Dropbox. All directories and files created within that folder are being assigned to the user "_mysql" and ...

Django/SQL: keeping track of who who read what in a forum

I'm working on a not-so-big project in django that will among other things incorporate a forum system. I have most of the system at a more or less functioning state, but I'm still missing a feature to mark unread threads for the users when there are new posts. The thing is I can't really think of a way to properly store that informatio...

Which database should I use to store records, and how should I use it?

I'm developing an application that will store a sizeable number of records. These records will be something like (URL, date, title, source, {optional data...}) As this is a client-side app, I don't want to use a database server, I just want the info stored into files. I want the files to be readable from various languages (at least pyt...

help with sql query

hi i have 2 tables: Mal: IdNum,Name Trap: IdNum,Tdate,Name input: from Tdate to Tdate and Name i need all the IdNum that in Mal but not in Trap and the input condition i work on oracle 10g thank's in advance ...

Retrieving image from sql database

Hi all, Previously i had problem with inserting image into sql database. Now i have solved this problem and able to insert image in sqldatabase. Now I am facing problem with retrieving the image from database table. Here is my retrieving code: showimage.ashx: <%@ WebHandler Language="C#" Class="ShowImage" %> using System; using System.W...