database-queries

What does null extended mean in relational queries?

I'm reading a paper on SCOPE that discusses SQL like query semantics for big data applications. It does not follow how SQL deals with null values and discusses "null-extended" variables, which I have not encountered before. Consider the pseudo-query SELECT * FROM DATA WHERE A != B What does "the predicate A != B is satisfied only f...

Id of object before insertion into database (Linq to SQL)

Hi, From what I gather, Linq to SQL doesn't actually execute any database commands (including the opening of database connections) until the SubmitChanges() method is called. If this is the case, I would like to increase the efficiency of a few methods. Is it possible for me to retrieve the ID of an object before inserting it? I'd rath...

Post processing attendance data with Django

I have a web app which tries to determine when people are attending events. class Attendee(models.Model): location = models.ForeignKey(Location) user = models.ForeignKey(User) checked_in = models.DateTimeField() checked_out = models.DateTimeField() last_active = models.DateTimeField() An Attendee is checked in when...

How to run SP in sql server after every 1 hour ?

I have a table on which i want to perform some operations after every hour. For this I created a Stored Procedure but dont know how to call it after every hour. I know their are some kind of scheduled jobs but how to use them. Is it their some kind of service also that keeps on running continously every second where i can place my piec...

LINQ vs. nHibernate

Question: Until now, I didn't know LINQ was an ORM tool. I always saw it as some new kind of SQL query language. So I very recently started using nHibernate. So my question: What would be the advantages and disadvantages of LINQ in comparison to nHibernate? As far as I found out, the differences are that LINQ requires .NET > 2.0 (unle...

C# Storing alternate text in session variable or retrieving from db

I'm building a web system and various clients will have alternate text for default instances throughout the site. One place is the main nav but there are others. The default may be "project" but they may want to call it "event". I'm heading down the road of calling all the terminology settings (there's a list of about 15) and creating...

Help with LINQ query

I'm trying to retrieve columns based on their corresponding key. "Select * from diamond where p_Id="+p_Id I followed MSDN sample and they were doing it like this way: CurrencyManager cm = ((CurrencyManager)this.BindingContext[myDatabaseDataSet, "Items.ItemDiamond"]); IBindingList list = (IBindingList)cm.List; but lis...

How to club the results of two SQL queries?

SELECT * FROM( (SELECT count(DISTINCT RECEPIENT_ID) as NoOfUsers, TO_CHAR(ACTN_TAKE_DATA_TM,'YYYY-MM-DD') as accDate FROM ALRT_PLATFORM_ALRT_HSTRY where APPL_CD like 'EBP' and ALRT_RSPNS_FROM_CLIENT_ID like 'BB' group by TO_CHAR(ACTN_T...

(Design Idea) Best Practise to reserve record for multi-process workflow engine

I'm designing multiple process to query job from database. Each job wake up once per minute to query task and send to workflow system. I need advice about which best way to mask record and query it and not duplicate with other process. ...

Find maximum number of logged on users in SQL

Hi, I want to keep tabs on the number of concurrent users of my application. I therefore log a time_start and a time_stop. If I now want to query the database for the maximum number of logged on users and return the start date, how would I do that. The table looks like this: id | time_start | time_stop ----+---------...

SQL server query to get the list of columns in a table along with Data types, NOT NULL, and PRIMARY KEY constraints

Hey guys. I need to write a query on SQL server to get the list of columns in a particular table, its associated data types and their length and if they are not null. I have managed to do this much. But now i also need to get in the same table against a column - TRUE if it is a primary key. How do i do this ? This is how the output s...

Help writing database queries for derby?

I have a database containing multiple tables (Person, Parents, etc) Person table has certain attributes particularly ssn, countryofbirth and currentcountry. Parents table has ssn, and fathersbirthcountry The ssn in Person is the same ssn in Parents - that is how they're linked. I'm trying to output the SSNs of all people who have the...

How to virtually delete data from multiple tables that are linked by a foreign key ?

I am using Sql Server 2005 This is a part of my database diagram. I want to perform deletion on my database which will start from tblDomain up tp tblSubTopics. Consider that each table has IsDeleted column which has to be marked true if request was made to delete data. But that data shoud remain their physically. Tables which will ...

How do I get 5 records before AND after a record with a specific ID?

I have a table named scores with the columns id and score. I want to access a specific record by its id as well as the 5 records before and after it. Is there a way in SQL to say "grab the score with the id of n and x items before and after it?" ...

Designing a general database interface in PHP

I'm creating a small framework for my web projects in PHP so I don't have to do the basic work over and over again for every new website. It is not my goal to create a second CakePHP or Codeigniter and I'm also not planning to build my websites with any of the available frameworks as I prefer to use things I've created myself in general....

algorithm advice for finding maximum items within a time period

Hi everyone. I have a database schema that is similar to the following: | User | Event | Date |--------|---------------|------ | 111 | Walked dog | 2009-10-1 | 222 | Walked dog | 2009-10-2 | 333 | Fed Fish | 2009-10-5 | 222 | Did Laundry | 2009-10-6 | 111 | Fed Fish | 2009-10-7 | 111 | Walk...

Is there a way to list all the database queries my wordpress install is making for a given event?

Using a method similar to the one described here: (http://stackoverflow.com/questions/14873/how-do-i-display-database-query-statistics-on-wordpress-site), I can see the total number of queries being made when I load a page. Now I'd like to output a list of the queries that are being made when the page loads. This would allow me to se...

methods of joining 2 tables without using JOIN or SELECT more than one distinct table in the query

Is there a way of joining results from 2 tables without using JOIN or SELECT from more than one table? The reason being the database im working with requires queries that only contain SELECT, FROM, and WHERE clauses containing only one distinct table. I do, however, need information from other tables for the project i'm working on. More...

MYSQL - Selecting a specific date range to get "current" popular screensavers.

Let's say I have a screensaver website. I want to display the CURRENT top 100 screensavers on the front page of the website. What I mean is, "RECENT" top 100 screensavers. What would be an example query to do this? My current one is: SELECT * FROM tbl_screensavers WHERE WEEK(tbl_screensavers.DateAdded) = WEEK('".date("Y-m-d H:i:s",str...

How to implement temporarily undoable operations in PHP and JavaScript?

I would like to implement operations that is undoable in a short time after the user have done them. I.e. if a user upvotes a photo in a photo-site, he/she can undo the vote within 30 seconds. This is similar to how the voting on StackOverflow is working, you can undo your votes for a short time. How should I implement it? I guess that ...