database-design

ISO advice on best way to store particular group of values

I'm adding a number of fields to a table that stores information on vessels (ships). The values are related to fuel consumption. There are eight values, which at any time four can be used: At port IFO 180 At port IFO 380 At port MDO At port MGO Sailing IFO 180 Sailing IFO 380 Sailing MDO Sailing MGO Now, a user can enter a value for...

Explaining row and column dependencies

This is a simple and common scenario at work, and I'd appreciate some input. Say I am generating a report for the owners of a pet show, and they want to know which of their customers have bought how many of each pet. In this scenario my only tools are SQL and something that outputs my query to a spreadsheet. As the shop owner, I might ...

Sanity Check: Floats as primary keys?

I'm working with an old sql server 2000 database, mixing some of it's information with a new app I'm building. I noticed some of the primary keys in several of the tables are floats rather than any type of ints. They aren't foreign keys and are all unique. I can't think of any reason that anyone would want to make their unique primary ke...

How to build a category table

Sorry for the not so great title, but I'm curious how people build a category table in SQL given the following example Two columns: ID, CATEGORY Which of these ways would you name the columns? ID, CATEGORY ID, DESCRIPTION CAT_ID, CAT_DESC Or something else? Just wondering what other people do. Sorry if this is less than clear. ...

What databases do Web's biggest sites run on?

This question is meant to serve as a list of databases and their configurations that the major web-sites use and would be a great reference for anyone thinking of scaling their web-site to the size of Twitter, Facebook or even Google. Please keep your answers to a minimum and be sure to cite any sources used. EDIT: Also, please bold b...

Approch for designing Database for Mobile Applications?

Possible Duplicate: Standard Database Schema for eBook Application ? Hi Friends.. I need to design a design a database for e-Book Application (e-Book DataStore), it will used for holding all information or contents about e-Books,This database will be used to Mobie applications, i.e., when a user seach for anybook, it access the...

MySQL Query Performance on Calendar Database

Hello all. I am creating a calendar webapp and I'm kinda stuck between a performance vs storage issue in the creation and subsequent queries of my events table. The concept is "how to make a table with repeating events (daily/weekly)?" Here is my current solution: CREATE TABLE `events` ( `eventid` int(10) NOT NULL AUTO_INCREMENT, ...

How do I properly store data relationships with Microsoft Azure Table Storage?

Coming from a Relational world things are obviously very different with the Azure Table storage. The first major thing I've run into is how to properly store Many-to-Many relationships. For example, I may have a system that keeps track of Users and Books that they own. I found one other post here on SO that suggested to have a String Pr...

Accounting System design & databases

I am working on a simple invoicing and accounting applications, but I am totally lost on how to represent accounting-transactions(journal-entries) in a database. Using a separate debit and credit column in the database seems like one way, but most of the Open Source Accounting I have seen use a single amount column. This I assume simplif...

Database Design for Threaded Conversations

I have a scenario that looks like this: User A is a registered user. User B is just a visitor (not registered). User B needs to send a message to User A (without having to register). User A needs to reply to User B. Repeat steps 3 & 4 ad infinitum. So basically I've implemented this simple table structure: id id_message (= 0 on firs...

Do I need a surrogate key in a one-to-many relationship?

create table A (id int(10) not null, val1 varchar(255), primary key (id)); [a] create table B (a_id int(10) not null, val2 varchar(255), foreign key (a_id) references A (id)); [b] create table B (id int(10) not null, a_id int(10) not null, val2 varchar(255), foreign key (a_id) references A(id), primary key (id)); By choosing [a], I ca...

Is there a database implementation that has notifications and revisions?

I am looking for a database library that can be used within an editor to replace a custom document format. In my case the document would contain a functional program. I want application data to be persistent even while editing, so that when the program crashes, no data is lost. I know that all databases offer that. On top of that, I wa...

C#: How would you store arbitrary objects in an SQL Server?

Lets say you have various objects of arbitrary type that you would like to store in a key+value type of table. Key could for example be an int, string or guid. What would the value be? String, Binary or something else? And how would you store and load the objects? I would think some sort of serialization, but what kind? I have one so...

Database and relationship design when subclassing a model.

I have a model "Task" which will HABTM many "TaskTargets". When it comes to TaskTargets however, I'm writing the base TaskTarget class which is abstract (as much as can be in Rails). TaskTarget will be subclassed by various different conceptualizations of anything that can be the target of a task. So say, software subsystem, customer ...

Determining Formula Field

Hi all, Guys, I am using SQL Server 2000 and executing the sp_columns stored procedure to get a layout of my table. One of my fields is a formula field and my question is, how can I determine this through sp_columns? sp_columns does not seem to show this information. THanks in advance ...

User Table in Separate DB

Note: I have no intention of implementing this, it's more of a thought experiment. Suppose I had multiple services available through a web interface. At least two of which required user registration and some data in a database. A single registration would grant access to all services. Like Google (GMail, Google Docs, etc.). Would ...

First name, middle name, last name. Why not Full Name?

I am trying to find a better approach for storing people's name in the table. What is the benefits of 3 field over 1 field for storing persons name? thanks. ...

Quick tips on relational database design for MySQL

Hi, I have a webapp I'm making that stores user information, and their preferences regarding the app. Is this something worth splitting into two databases? I was thinking one table "users" with fields "id, useridfromFacebook, facebookRealName" (so 1, 52052025295, Alex McP), and then have a table "preferences" with fields "id, useridfro...

How to share One-To-Many table

I am trying to create a database to hold my address book but I've ran into a slight problem. My database is supposed to hold individual contacts along with company contacts. That is an entry can be either for an individual or a company. As you know both individuals and companies have addresses and I want a One-To-Many relationship betwee...

Polymorphic habtm relationships with Rails/ActiveRecord

How would I go about creating a polymorphic has_and_belongs_to_many relationship with Rails/ActiveRecord? Most of the examples I see involve creating a belongs_to relationship which limits my polymorphic-side to being related to only one parent: Table: Task Table: Tasks_Targets Table: CustomerStore Table: SoftwareSystem Both Custom...