database-design

Adding foreign key constraints in archive tables

Say I have these tables and Oldbookings is an archive table containing rows from Bookings made a year ago. Also, assuming that such constraints were already defined in Bookings: FOREIGN KEY (cusNo) REFERENCES Customers(cusNo) FOREIGN KEY (flightNo) REFERENCES Flights(flightNo) Would it make sense to define these contraints (foreign ke...

Database Design with a flat considering time

Background: School counselors will login and make comments about their meetings with students. Issues: PHP 4 server Flat File or CSV Suppose I have HTML form with the following text fields user id date comments How can I create an effective record keeping to be able to display the comments that have been made and next to them ...

MySQL database-design question

Situation Say I have the following: a table items a table lists to which these items can be linked a table users Condition: a list can belong to all or one specific user What I'd like to do is create "global" lists that exist for ever user. But there should be a possibility to "overwrite" this global list with a user-specific one. E...

How do I design a Localised Content table that can join to a number of different tables (the relationship needs to be generic...)

I know that this isn't exactly normalised, but bringing all of the localised data throughout my application into just a few tables will help me out a lot. I have to be able to link some generic table to a LocalisedContent table which will contain different rows for each of the localised key-value pairs of the generic table joined to it....

Databases and 3rd Normal Form.

Do you always design databases in at least Third Normal Form (3NF)? Why? ...

SQL Server table relationships practice

What is the recommended way in this situation: Customer ..* <-------------> 0..1 Car So there is a Customer table and a Car table, Customer can have zero or one Car, the Car can be linked to many Customer tables. Should I add a nullable CarID column to Customer or Should I create a Customer_Car_Map table containing CustomerID and Ca...

Many-to-many link table design : two foreign keys only or an additional primary key?

Hello experts, this is undoubtedly a newbie question, but I haven't been able to find a satisfactory answer. When creating a link table for many-to-many relationships, is it better to create a unique id or only use two foreign keys of the respective tables (compound key?). Looking at different diagrams of the Northwind database for exam...

Is Single-Table Inheritance the right solution for my Rails problem?

Greetings, all, I'm working on an application in Ruby on Rails where we need to keep track of a bunch of external services for each user (for example, Facebook, MySpace, Google, SalesForce, Twitter, WordPress, etc) that the app will access on behalf of the user. For some services, we will need to store an (encrypted) username and passwo...

How can I extend this Ruby ActiveRecord model?

I'm creating this little show scheduler thing. I have the table shows, with title:string and description:text. I want to add days and times to the show (each show can have multiple days, and each day has their OWN times). How might I go about doing this? I was thinking of making a times table. With the columns (show_id, day, and time)....

How to store old version of ID String in Database Design?

I am building a small database for a lab. We have some rules to make a ID String for every Item, so i do not want to store it in my database. The problem is that some times changes in data, for example the person response for that item changed, causes the chang of ID String. But i can not correct it for printed docs. How can i store the...

Float or decimal for prices?

Hi all, Which type (Float or decimal) is best used to store prices in a database? Thx ...

Database design of Field that is calculated using other database values

For a rating system that is dependent on factors such as votes, how do they store the reputation? Eg. Stackoverflow. Do they calculate it everytime the page loads? eg. searching all posts and adding and multiplying? Store it in a reputation field on the user table and increment it everytime a vote is being casted? Which is the most ...

table relationships, SQL 2005

Ok I have a question and it is probably very easy but I can not find the solution. I have 3 tables plus one main tbl. tbl_1 - tbl_1Name_id tbl_2- tbl_2Name_id tbl_3 - tbl_3Name_id I want to connect the Name_id fields to the main tbl fields below. main_tbl ___________ tbl_1Name_id tbl_2Name_id tbl_3Name_id Main tbl has a Uniq...

Users database structure that allows multiple simultaneous logins to same account

A feature that is currently missing from one of my web apps is that a single user can only be logged in on one machine at a time. That is, if the users logs in elsewhere, his previous session will be logged off. This is due to my current users table having the columns: user: id, username, hash, salt... cursession When each user logs ...

How to model this classes/database tables?

Hello. I have to model classes and database tables for a "User" entity. This "User" entity have this properties: User Name Age Gender Email But I have 2 user's type: "Paid users" and "Free users". Each one have his own properties: Paid User Fee Rate Free User Expiration Date Level "Paid User" and "Free User" ar...

Optimal Database Structure for MicroStrategy

I have spent most of my career developing data warehouses\marts as Star Schemas because they were typically used in conjunction with Microsoft's Analysis Services. However, we are starting to leverage MicroStrategy 9.0.1, and I have been told that Star Schemas are less than optimal for this platform. MicroStrategy does not have an offi...

SQL Finding multiple-line duplicates

At my worki we have data stored in a database, the data is not normalized. I am looking for a way to find what data was duplicated. Our Data base has 3 rows columns, Name, State, Strategy This data might looks something like this: OldTable: Name | State | Strat -----+-------+------ A | M | 1 A | X | 3 B | T | 6 C ...

Is it a bad design to duplicate data in transaction table?

I have 2 tables Product Product -------- ProductID ProductName and SalesTransaction. SalesTransaction -------- TransactionID ProductID ProductName User's requirement state that "Product's name can change over time but this modification must not have any effect on already exist transaction". I want to know, is my design good for thi...

My own content management system on Struts how do i proceed?

I am trying to build a Content Management System in java I wish to use Struts as my MVC framework.How should i proceed and what things should i need to keep in mind while developing my own CMS?How should i design my database.? I am working on a project where i will require managing user articles,events,communities..etc. ...

General understanding of star schema design

So, I think I understood what to put in dimensions, what in the fact table, and how to achieve this. Now I got the problem, that I have this dimension 'product' and a dimension 'productProperties'. I had to split this, cause otherwise my natural key in 'product' wouldn`t have been unique anymore. I asked this in this question. So my '...