database

Ruby on Rails time match database start and end times

I've been banging my head at this one: I have a table with columns start_time an end_time as well as start_date and end_date, and I have a Time object called test_time. I need to be able to match these values in a sql query. ie. Reservation.find :all, :conditions => ["'start_time' <= ? AND 'end_time' >= ?", test_time, test_time]...

order datatable by relevance using linq by column values which are comma sperated

I have a Datatable that contains a column called Tags, Tags can have values such as row[0] = Tag1 row[1] = Tag1, Tag2 row[2] = Tag2, Tag3 row[3] = Tag1, Tag2, Tag3 row[4] = Tag4, Tag6 and are seperated by comma's etc.. I have the value of Tags for the current document and have run a query to select all other documents that have eith...

Mix of Database design, multilang and User tracking Q for user content website

Few questions, though i'll ask it all in 1 post. 1) Any difference between a Lookup & reference table? And what is best practice on how many to use? Example List of Cities, Countries, Account types, Category names, User tags, Movie names - are these all lookup, reference or some other type of tables? Key is all this data will be search ...

Is this a valid use of NULL foreign keys?

Hi. Consider this very small contrived subset of my schema: SensorType1 ID : PK SensorType2 ID : PK Reading Timestamp Value SensorType1_ID FK -> SensorType1 SensorType2_ID FK -> SensorType2 Some readings are for SensorType1, some are for SensorType2. I would probably add a constraint to ensure exclusively one of those FK's is alway...

Database to choose for game

I'm working on a game (something like chess) where every move needs to be saved into a database per move. Since it's very important that both reads and writes are fast, and I don't need complex queries, I'm probably going to go with a NoSQL solution. Which one though? I'm thinking about MongoDB but will its durability be an issue? It'...

foreign key problem with my database

I am creating a social networking site and am working on a friends table and dont know what Im doing wrong. I have a users(userId, name - userId is primary key) and another table called friends(friend1, friend2, status). friend1 and friend2 are foreign keys to userId on update and delete are set to cascade table users has an entry wit...

Insert User Data to Database with INSERT statement

From a user form: I am trying to insert the following data: 1) First Name 2) Last Name 3) Major 4) Graduation Year I am able to connect to the database, and select the database I need--but I am unable to insert the data from the form. I am able to create records, but the data is not being saved to the database. Basically, right now I'm ...

Is there a faster way to read from a file and insert into SQLite.

Afternoon everyone. I'm not that familiar with SQLite so I haven't messed with all of the settings of the database. I'm rather familiar with SQL Server, Oracle and even some Access and mySQL. Well, currently, I'm taking a file with 110,000+ records and reading the file line by line, parsing the data and running an insert statement to ...

Passing class instantiations (layering)

Program design: Class A, which implements lower level data handling Classes B-E, which provide a higher level interface to A to perform various functions Class F, which is a UI object that interacts with B-E according to user input There can only be one instantiation of A at any given time, to avoid race conditions, data corrupti...

Convert a "timestamp with time zone" column field to the current timezone of the server

In Oracle how do I convert a "timestamp with time zone" to the current time zone of the server? I need to dynamically figure out what the current time zone of the server is. create table test_table1 (rec1 timestamp with time zone) insert into test_table1(rec1) values ( to_timestamp_tz('1/1/1900 09:00:00 AM US/EASTERN','dd-mm-yyyy hh:mi...

Where should I store my widget's preferences on the Configuration page on Android?

Hi all, ^Question^ I think that it would be too complex to open a database. Does using shared preferences make my app's data size become big. Is there a temporary storage place for my data or should I delete the data in the shared preferences for that widget. Short code samples are very appreciated :) Thank you ...

Import MySQL-DB-Dump into a Rails app using a migration file

I have an old PHP application with a bunch of MySQL tables. I want to rewrite it with Rails(3) and want to import the old data. How can I write a migration-script to import the MySQL-Dump into a sqlite DB? ...

asp.net: avoid too many queries repeatedly to database

Hi, Among methods: static variables, viewstate, session and cache for avoiding on loading repeatedly and less making queries to the database. What do you think the best method of the 4 above? I Think Cache is the best one? Or any other methods better in Asp.net 3.5 or higher? Please advise me on this. Thanks in advance ...

Unable to Select Record from Database

I am learning PHP and SQL, and I'm trying to figure out how to select a record from a database. I created a function called selectById() Right now in the browser displayed is "Error:" but, no specific error was displayed. // function selectById -------------------------------------------------------------------- function selectBy...

should i consolidate these database tables . .

i have an event calendar application with a sql database behind it and right now i have 3 tables to represent the events: Table 1: Holiday Columns: ID, Date, Name, Location, CalendarID Table 2: Vacation Columns: Id, Date, Name, PersonId, WorkflowStatus Table 3: Event Columns: Id, Date, Name, CalendarID So i have "generic events" whic...

cakephp is not able to connect to database...

Hi guys I am a cakephp newbie and I tried to setup my connection to mysql. I had it worked before but after I changed my mysql database name, it won't connect anymore even thought I changed the database name in database.php inside the config folder. Do I have to run the cakephp console again?? Your tmp directory is writable. The File...

what's the best way to save sessions in a database?

i'm planning on making my own custom session handling functions. i want to save it in the database but i have some doubts. is it viable or will just slow down my app? i have to save the session after each set or can i just save it all at once? because i had this idea to put this function in the class destructor method. so, when the pro...

SQL queries exceedingly slow when referencing primary key

I have a MS SQL table with about 8 million records. There is a primary key (with clustered index with only 0.8% fragmentation) on the column "ID". When I run seemingly any query referencing the ID column, the query takes very long (and in fact ultimately crashes my application). This includes simple queries like "SELECT * FROM table WH...

Help to complete a cursor

Hi, I am working on cursors. I want to create a cursor to display each customer’s information and the product that he has purchased more. For this aim, I wrote the following cursor: declare myCursor cursor for select Customers.CustomerID, Customers.ContactName, Products.ProductName, SUM(Quantity) as Total from Customers inner join Or...

PHP dehashing the password

Ok. thats clear that one must store hashed password in the database but in case a user does not remembers the password and want to retrieve it back, then obviously the user wont like to have the hashed password. If the password is hashed with md5 or additional like salt and sha1 then how to retrieve back the password. ...