database

What is wrong with my Oracle 10gr2 check constraint? Trying to enforce a date range

I want to enforce CHECK constraint on a date range such that all dates in column BIRTH_DATE are less than tomorrow and greater than or equal to 100 years ago. I tried this expression in a CHECK constraint: BIRTH_DATE >= (sysdate - numtoyminterval(100, 'YEAR')) AND BIRTH_DATE < sysdate + 1 But I received the error "ORA-02436: date or ...

Looking for a recommendation on record-locking within a distributed system

We're trying to come up with a recommended design pattern for our team when it comes to record locking. The typical school of thought goes something like this: 1. User picks a record from a list 2. Lock the record with the user id 3. Load the locked record record (no lock, then someone beat ya to it). Am I missing something, or does th...

Two foreign keys instead of primary

Hello! I was wondering, is there any possibility to create a table without a primary key, but with two foreign keys, where the foreign keys pairs are always different? For example, a STOCK table with item_id and warehouse_id as foreign keys from ITEMS and WAREHOUSES tables. So same item can be in different warehouses. The view of the tab...

Design Hints, Payroll System...repost

Hi, We are designing a Payroll Generation System for a client. The organization we are targeting has a hierarchy as follows: Company -> Cluster -> Business Unit (BU) -> Department -> Employee The salary for an employee is made up of various salary components. Each salary component has 3 rules associated with it, a Calculation Rule (Ca...

Is there a difference betweeen Select * and Select [list each col]

I'm using MS SQL Server 2005. Is there a difference, to the SQL engine, between SELECT * FROM MyTable; and SELECT ColA, ColB, ColC FROM MyTable; When ColA, ColB, and ColC represent every column in the table? If they are the same, is there a reason why you should use the 2nd one anyway? I have a project that's heavy on LINQ, and I...

ORM for Database with 1000+ Tables

I'm looking for a solid ORM for .NET that can handle over a 1000 tables and entities. What can you suggest? Any comments would be appreciated, but those from people who have actually dealt with this challenge and a description of how with what they dealt with it would be appreciated even more. ...

Payroll System Design, Business Logic in SPs or Application Layer (C#.Net), Maintainability - Repost

Hi, We are designing a Payroll Generation System for a client. The organization we are targeting has a hierarchy as follows: Company -> Cluster -> Business Unit (BU) -> Department -> Employee The salary for an employee is made up of various salary components. Each salary component has 3 rules associated with it, a Calculation Rule (Ca...

Ordering numbers that are stored as strings in the database

I have a bunch of records in several tables in a database that have a "process number" field, that's basically a number, but I have to store it as a string both because of some legacy data that has stuff like "89a" as a number and some numbering system that requires that process numbers be represented as number/year. The problem arises ...

Boilerplate for a professional PHP team development environment

I would like to get a general consensus for the minimal/boilerplate professional PHP team development environment. I can not find this information anywhere on the web. In the open-source world there are so many choices and so many ways to do things but I've yet to find any common best-practice for the infrastructure/plumbing side of th...

SQL Server 2005 - best way to move data between two databases when primary keys have changed

Hi, i know this should be db 101, but its just not as clear as it can be for me. I am using SQL2005 express and i want to copy data from databaseA to databaseB. DatabaseB already contains existing data - it may even contain data with pk's that have changed or dont exist - for example: DataBase A pk1 = peaches pk2 = apples DataBase B ...

Update more than one row atomically

I need to execute a select and then update some of the rows in the ResultSet in an atomic way. The code I am using looks like (simplified): stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery("SELECT ..."); while (rs.next()) { if (conditions_to_update) { rs.update...

Should database variable-length text fields be powers of 2?

A friend of mine claims that in a typical database, using (for example) nvarchar[256] will give marginally better performance than nvarchar[200] or nvarchar[250] because of the granularity of page allocations. Is there any truth to this whatsoever? Thanks! ...

"Pivoting" a Table in SQL (i.e. Cross tabulation / crosstabulation)

I'm working on trying to generate a report from a couple of database tables. The simplified version looks like this Table = Campaign CampaignID Table = Source Source_ID | Campaign_ID Table = Content Content_ID | Campaign_ID | Content_Row_ID | Content_Value The report needs to read like this: CampaignID - SourceID - ContentRow...

how much does facebook denormalize their databases to break things up by network and therefore shrink the tables and speed the system?

any bit of info will be helpful here. or does anybody else huge do something interesting here too? ...

What are some good open source MySQL GUIs for Windows?

I mainly use CocoaMySQL and YourSQL on the Mac, but I am looking for suggestions for Windows, in which I can connect to the database and manage it using the interface. ...

Storing arrays in databases

What is the most efficient way to store large arrays (10000x100) in a database, say, hsqldb? I need to do this for a certain math program that I'm writing in java. Please help. The whole array will be retrieved and stored often (not so much individual elements). Also, some meta-data about the array needs to be stored about the array. ...

database autocommit - does it go directly to disk?

So I know that autocommit commits every sql statement, but do updates to the database go directly to the disk or do they remain on cache until flushed? I realize it's dependent on the database implementation. Does auto-commit mean a) every statement is a complete transaction AND it goes straight to disk or b) every statement is a c...

c# query ms access against sql server

I have been asked to setup a course leaflet system for a college. For whatever reason in the past their current system is not linked to their actual course file, they wish to close this link so course leaflets are related to actual course codes. Unfortunately their course file is a ms access database linked to many of their existing syst...

Database denormalization opportunity

I'm looking for a strategy in as far as stopping the repetitive problem of branching out tables. For example as a fictitious use case, say I have a table with users that contains their name, login, password and other meta data. In this particular scenario, say the user is restricted to login per a specific subset of IP(s). Thus, we have ...

Do different databases use different name quote?

For example, mysql quote table name using SELECT * FROM `table_name`; notice the ` Does other database ever use different char to quote their table name ...