database-design

Designing a game database

I'm trying to design a database to record game histories for a game I'm working on. I have 3 different tables: users, gamehistories, and gamescores. Columns for tables: users: uid, displayname, email gamehistories: gid, pubID, start (datetime), end (datetime) gamescores: gid, uid, score I am trying to produce the following result...

"FirstName" and "LastName" store in database USER or USER_PROFILE table?

Currently I store the user's "FirstName" and "LastName" in the USER table, but i also have a USER PROFILE table (which provides additional information about the user) and it would makes sense to have the user's "FirstName" and "LastName" in the USER PROFILE table aswell. So what do i do? make two copies of "FirstName" and "LastName"? ...

How do you store sets in Cassandra?

I'd like to convert this JSON to a data model in Cassandra, where each of the arrays is a set with no duplicates: var data = { "data1": { "100": [1, 2, 3], "200": [3, 4] }, "data2": { "k1", [1], "k2", [4, 5] } } I'd like to query like this: data["data1"]["100"] to retrieve the sets. Anyone know how you might m...

what is purpose of database scheme

What is the purpose of database scheme? Where can I find more information about this? It's not table, it's not database, what is it? ...

What is a mantainable way of saving "star rating" in a database?

I'll use the jQuery plugin for presenting the user with a nice interface The request is to display 5 stars, up to a total score of 10 (2 points per star). By now I thought about using 7/10 as a format for that value, but what if at some point in the future I'll receive a request like We would like to give users more choice, let's i...

How it is better to organise a large database of addresses?

How it is better to organise a large database of addresses? It is need to create mysql database of addresses. How it is better for organising? I have two variants: 1) cuontries id|name 1 |Russia cities id|name 1 |Moscow 2 |Saratov villages id|name streets id|name 1 |Lenin st. places id|name |country_id|city_id|village_id...

Simplifying wide, unnormalized tables in Rails

Background I'm designing a Rails app to record research data. Most of it can be conceptualized as being "survey" (or "questionnaire") data. We already have several Access databases and CSV files that hold this data. The existing design is that each survey has its own table with one column per question. Many of these tables have 100+...

Survey table/model design in Rails

I have some survey data which is currently stored in tables that are 100+ columns wide (one column per question). To simplify it, I've been thinking about making some models like: Survey Question Response However, I'm not sure how to approach it through Rails because: I need nice views (better than autogenerating forms) for many s...

Bus Timetable database design

hi, I'm trying to design a db to store the timetable for 300 different bus routes, Each route has a different number of stops and different times for Monday-Friday, Saturday and Sunday. I've represented the bus departure times for each route as follows, I'm not sure if i should have null values in the table, does this look ok? route...

Database design for invoices, invoice lines & revisions

I'm designing the 2nd major iteration of a relational database for a franchise's CRM (with lots of refactoring) and I need help on the best database design practices for storing job invoices and invoice lines with a strong audit trail of any changes made to each invoice. Current schema Invoices Table InvoiceId (int) // Primary key Job...

Storing "derived" values vs calculating them on extraction

When you have values which only depends on one or more other fields +/- constants (say retail price & discount price), is it better to store those values too or to calculate them "on the fly" when retrieving the data? ...

Database Desing - when to split data into multiple tables?

I have a table of Animals: Animals Id Name 1 Dog 2 Cat 3 Rabbit Each animal has a portfolio therefore I have two methods of defining the database tables. METHOD 1: Portfolio Id AnimalId Date 1 1 01/01/2001 2 2 20/03/2009 3 3 05/03/2009 4 1 01/04/2005 METHOD 2: DogPortfol...

DB Strategy for inserting into a high read table (Sql Server)

Looking for strategies for a very large table with data maintained for reporting and historical purposes, a very small subset of that data is used in daily operations. Background: We have Visitor and Visits tables which are continuously updated by our consumer facing site. These tables contain information on every visit and visitor, ...

Database Table of Boolean Values

What's the best method of storing a large number of booleans in a database table? Should I create a column for each boolean value or is there a more optimal method? Employee Table IsHardWorking IsEfficient IsCrazy IsOverworked IsUnderpaid ...etc. ...

Database design MySQL using foreign keys

I'm having some a little trouble understanding how to handle the database end of a program I'm making. I'm using an ORM in Kohana, but am hoping that a generalized understanding of how to solve this issue will lead me to an answer with the ORM. I'm writing a program for users to manage their stock research information. My tables are...

Building a wiki like data model in rails question.

I have a data model in which I would like to have an item that has a description that can be edited. I would like to also keep track of all edits to the item. I am running into issues with my current strategy, which is: class Item < ActiveRecord::Base has_one :current_edit, :class_name => "Edit", :foreign_key =>...

Creating an ER diagram for hsqldb that exports SQL

Hi fellows! I'm currently designing a DB scheme. I have to use hsqldb. - Normally I like creating an ER diagram, and I export the SQL source. Therefore I'm looking for a tool that automatically transforms my ER diagram into hsqldb sql code. Using MySQL Workbench or some sort of web interface (http://ondras.zarovi.cz/sql/demo/) seems to...

Why is using a common-lookup table to restrict the status of entity wrong?

According to Five Simple Database Design Errors You Should Avoid by Anith Sen, using a common-lookup table to store the possible statuses for an entity is a common mistake. Edit + Answer: The figures in Anith's article aren't well labelled - I thought both Figure 1 and Figure 2 are examples of bad design, whereas Figure 2 is good design...

structured vs. unstructured data in db

the question is one of design. i'm gathering a big chunk of performance data with lots of key-value pairs. pretty much everything in /proc/cpuinfo, /proc/meminfo/, /proc/loadavg, plus a bunch of other stuff, from several hundred hosts. right now, i just need to display the latest chunk of data in my UI. i will probably end up doing some ...

How to explain to users the advantages of dumb primary key?

Primary key attractiveness I have a boss(and also users) that wants primary key to be sophisticated/smart/attractive control number(sort of like Social Security number, or credit card number format) I just padded the primary key(in Views) with zeroes to appease their desire to make the control number sophisticated,smart and attractive....