database

Checking if records exist in DB: in single step or two steps?

Suppose you want to get a record from database which returns a large amount of data and requires multiple joins. So my question would be, is it better to use a single query to check if data exists and get the result if it exists? Or do a more simple query to check if data exists then id record exists, query once again to get the result...

The woes of (sometimes) storing "date only" in datetimes

We have two fields from and to (of type datetime), where the user can store the begin time and the end time of a business trip, e.g.: From: 2010-04-14 09:00 To: 2010-04-16 16:30 So, the duration of the trip is 2 days and 7.5 hours. Often, the exact times are not known in advance, so the user enters the dates without a time: From: ...

[Database] How to model this one-to-one relation?

I have several entities which respresent different types of users who need to be able to log in to a particular system. Additionally, they have different types of information associated with them. For example: a "general user", which has an e-mail address and "admin user", which has a workstation number (note that this a hypothetical ca...

DbDataReader with DbTransactions

Its the wrong way or lack of performance, using DbDataReader combinated with DbTransactions? An example of code: public DbDataReader ExecuteReader() { try { if (this._baseConnection.State == ConnectionState.Closed) this._baseConnection.Open(); if (this._baseCommand.Transaction ...

monitor table in data base

hi all i want to make a web site to act as a monitor to a certain table in data base or act as a listenter on that table eg lets say i have table employees i want to make a web page that listen to changes occurs on that table (all DML operations) whenever a record is inserted i want this page alert me that a "1 row is inserted in tab...

Can I use ALTER DATABASE to rename a mysql database?

I am using PDO with PHP to create a new database and then a new user with privileges on that database. In case one of them fails, I want to rename the database and user so that they can be deleted later and the names are available. Is it possible to rename a mysql database using the ALTER DATABASE? ...

Strategies to use Database Sequences?

Hello all, I have a high-end architecture which receives many requests every second (in fact, it can receive many requests every millisecond). The architecture is designed so that some controls rely on a certain unique id assigned to each request. To create such UID we use a DB2 Sequence. Right now I already understand that this appro...

Creating a database view with boolean logic

My google search skills have failed me, and I am not a database expert by any means! I have a very simple database schema that looks like this: properties_id in the CANDY table is a foreign key to id in the EXPENSIVE_PROPERTIES table. The properties_id is only set if the candy is expensive. If it is expensive, then the correspondin...

SQL Server and distributed databases. How synchronize?

Hello everyone, I'm planning a project for managing multiple distributed databases and I am raising the question of how to efficiently synchronize the data. The project will be developed with technology. NET and SQL Server. There will be a local database in which the company will load data, some of these data (not all) should be synchr...

Database architecture - split vs. union vs. ?

Hey there, Got an interesting scenario I'd like to run past you guys re: DB architecture. There will be two entities: Application: This is more or less the core of the app we are building. It has a start and end date along with about 15 other properties. CalendarEvent: This a less used entity. It has a start and end date with maybe...

Client to access and edit a MySQL database remotely

Hey guys, So I have been given the host, username, and login information for a MySQL Database. I need a client that I can use to log in to the Database remotely and create/update tables and edit all the data. I found the MySQL Administrator client provided by them, but it seems you can do everything BUT edit the actual data with it. I...

What ORM to use in one process multiple db connections sinatra application?

Checked ActiveRecord, DataMapper, Sequel: some use globals (static variables) some require open db connection before loading source file with models. What ORM is better to use in sinatra application that uses different databases. ...

Sql server query using function and view is slower

I have a table with a xml column named Data: CREATE TABLE [dbo].[Users]( [UserId] [int] IDENTITY(1,1) NOT NULL, [FirstName] [nvarchar](max) NOT NULL, [LastName] [nvarchar](max) NOT NULL, [Email] [nvarchar](250) NOT NULL, [Password] [nvarchar](max) NULL, [UserName] [nvarchar](250) NOT NULL, [LanguageId] [int] ...

Is there is something like stored procedures in NOSQL databases?

I am new to NOSQL world and still comparing between nosql and sql databases, I Just tried making few samples using mongodb. I am asking about stored procedures when we send few parameters to one stored procedure and this procedure execute number of other stored procedures in the database, will get data from stored procedures and send ...

Best practices for managing updating a database with a complex set of changes

I am writing an application where I have some publicly available information in a database which I want the users to be able to edit. The information is not textual like a wiki but is similar in concept because the edits bring the public information increasingly closer to the truth. The changes will affect multiple tables and the update ...

PostgreSQL subselect problem

When I try to do the select statement, I always get the following error: ERROR: more than one row returned by a subquery used as an expression Only if there's only one result, it works. Why and how to fix? SELECT name from person p where id = ( select prs from leader where age(leader.lastcourse) > '1 year'); ...

How to invoke a method every time database is modified

I am writing a Ruby on Rails app and I want a method to be called every time the database is modified. Is it possible to do this without inserting a method call in every location where the database is modified? ...

What will happen if I change the type of a column from int to year?

I have a table in MySQL 4.0 which currently has a year field as a smallint(6) type. What will happen if I convert it directly to a Year type with a query like the following: ALTER TABLE t MODIFY y YEAR(4) NOT NULL DEFAULT CURRENT_TIMESTAMP; When the current members of column y have values like 2010? I assume that because the year ty...

PHP - How to use Php inside Php?

Can someone tell/show me how to use PHP inside PHP. I'm trying to make the URL of an image change depending on what value is in a MySQL database. Here's an example of what I'm trying to do. Bear in mind that $idx already has a value from the URL of the page. <?php $query = "SELECT * FROM comment WHERE uname='$idx'"; $result = mysql_que...

MySQL: Will a column-oriented engine be available in MySQL 5.5?

Will a column-oriented storage engine (e.g. InfiniDB) be available in the core release of MySQL 5.5? Meaning, not as a plugin but available with the core MySQL 5.5 bundle. ...