database-design

Database Storage of Formulas with Variables

This is a little complicated, so bear with me. My employer is asking to build a system that calculates task iterations from a set of variables. Each task in a project has a specific formula used to calculate the number of times the task needs to be accomplished ("iterations"). The formula could rely on constants, variables (number-ent...

MySQL - DB Design for "has many" issue across tables vs stored lists

Trying to figure out the best way to set up collection "lists" for users given the following data (pseudo code): user table = id, name, email cars table = id, make, model user_cars table = user_id, car_id, rating collections table = id, user_id, name Facts: Users can have many cars Users can have many collections Individual cars ...

Scheduling Employees - what data structure to use?

Question I'm trying to write a simple employee Scheduling software for about 10-20 people in my software development company. After some consideration I settled on writing a web app in Python, Ruby or PHP + Postgres/MySQL DB. While designing database models I began to wonder what data structure would actually be the best for that kind o...

Two tables or one table ?

Hi, a quick question in regards to table design.. Let's say I am designing a loan application database. As it is right now, I will have 2 tables.. Applicant (ApplicantID, FirstName , LastName, SSN, Email... ) and Co-Applicant(CoApplicantID, FirstName, LastName , SSN, Email.., ApplicantID) Should I consider having just one table beca...

ECommerce, products in category and category browsing

Hi Everyone, I am building an EC website for a customer and the project manager came with some strange ideas and I am struggling to actually implement what he sold to the client. Here comes my main issue and a quick summary how the system is setup: product are inside categories, categories could be children of an another category. So ...

How to store data that can be structured or non-structured at the same time?

I have a database with the following table: PATIENT (PATIENT_ID*, MEDICAL_EXAMINATIONS) where the field MEDICAL_EXAMINATIONS contains a free-text description of the exams undertaken by the patient. Recently, it was decided that medical examination can be reported EITHER as free-text (as always) OR in a structured way (divided in exa...

Dynamic or column-ized tsvector index?

I'm creating custom forum software for a site I'm building, which includes 2 tables (that are relevant to this question): topics and posts. A post belongs to a topic, and the topic contains the subject, while each post contains the body. Here is the basic table structures with the columns relevant to my question: CREATE TABLE topics (...

PostgreSQL analog of SQL Server index

Trying to recreate my SQL Server database on PostgreSQL. Everything is ok except I can't find how to recreate this index: USE [mytablename] GO CREATE NONCLUSTERED INDEX [myindex] ON [dbo].[mytablename] ([col1],[col2]) INCLUDE ([col3],[col4]) GO Will be very grateful for help. Alexey Update: http://img38.imageshack.us/...

Getting rid of hard coded values when dealing with lookup tables and related business logic

Example case: We're building a renting service, using SQL Server. Information about items that can be rented is stored in a table. Each item has a state that can be either "Available", "Rented" or "Broken". The different states reside in a lookup table. ItemState table: id name 1 'Available' 2 'Rented' 3 'Broken' Add...

server side db programming: why?

Given that database is generally the least scalable component (of a web application), are there any situations where one would put logic in procedures/triggers over keeping it in his favorite programming language (ruby...) or her favorite web framework (...rails!). ...

Is it a good idea to use rowguid as unique key in database design?

Hi there, SQL Server provides the type [rowguid]. I like to use this as unique primary key, to identify a row for update. The benefit shows up if you dump the table and reload it, no mess with SerialNo (identity) columns. In the special case of distributed databases like offline copies on notebooks or something like that, nothing else ...

Golf SQL Problem

I want to preface this by saying I believe the Right Way to handle this is probably to restructure the database tables BUT I have a job for a client where he is purchasing a database of most of the golf courses in the US. Since he will receive updates periodically from seller I have preserved structure as sent. (Nasty aside: jackass s...

Best Practices of Uploading XML files in a Web-Application

What's the best approach (industry standard) when another business needs to upload an XML file into your web-application on a regular basis? The contents of the XML must be stored in a table. And, the contents of the XML file needs to be inserted into a parent table and related child table with other relationships to other lookup table...

Database design concepts

I've just started a project and need a little push in the right direction. Here is my table structure: users departments sub-departments ------- ------- ------- id id id name name name email password created modified posts photos profiles ------- ...

DB design to use sub-type or not?

The database I'm designing has 3 major tables: BOOKS, ARTICLES, NOTES. Each book or article can have multiple notes, my original design was just like that, which means both notes on books and notes on articles go the 'notes' table. Here are the columns for the NOTES table: note_id note_type note_type_id note_content NOTE_TYPE can be ...

Database design for custom form builder (and storage of results)

I'm trying to implement a custom form builder, similar to those provided by Wufoo and Google. While I've created a simple UI to create these custom forms with, my issues lie in the database design. Upon creating the form, a JSON implementation is saved in the database (would like to improve this) and referenced to build the form that a ...

Getting related tags from SQL Server when you have filtered down

I asked this question before and got a great working answer. http://stackoverflow.com/questions/1648190/what-is-the-query-to-get-related-tags-like-in-stack-overflow but i realized that SOF actually takes it one step further as it supports multiple tag drilldown what i mean is, if click on the tag C#, that will filter to 20,000 questi...

mySQL - A new table of each page?

Every page on my application will display 1000 records and they are only needed on that page. Is it more efficient to have one huge table with an additional 'page id' column or to have a new table for each page? I imagine accessing data from a single small table would be easier than a huge one but it will make the database a bit of a m...

Dynamic Table Generation

First let me describe my situation so that you might be able to help me better. There are two parts. 1: I have a program that runs and analyzes a bunch of files. It generates a "report" that will later be fed into a website for DB storage and viewing. This report can contain pretty much any type of data, as the users can query pretty...

mysql - keyword search table - a good idea?

Is it a good idea to have a 'search table'? for example a search that can search 'users', 'groups' and 'pages' (facebook style) would have fields like keywords, userid, groupid, pageid that way the system can do a LIKE query on the keywords from one table. or would it be better like keyword1, keyword2, keyword3, keyword4, keyword5, u...