database-design

Mysql Database Design A Complex Shopping Catalogue Part

Hello All. I want to make an anouncement system. But i messed the database design part. The system will have unlimited categories and their items so every category will has strange properties for example car has a model, trade, manufacture date, color, gear type. . . and more another example Real Estate has a door count, gardened, du...

What size to pick for a (n)varchar column?

In a slightly heated discussion on TDWTF a question arose about the size of varchar columns in a DB. For example, take a field that contains the name of a person (just name, no surname). It's quite easy to see that it will not be very long. Most people have names with less than 10 characters, and few are those above 20. If you would mak...

How can I model this in a relational database?

I have a database for modelling a rental business. The database stores information for multiple Suppliers (owners) and each Supplier has a subset of depots. Each depot is closed certain days of the year, some are specific to that depot (might be closed every saturday or a whole week at thanksgiving) and others are global (all depots are ...

database design for multiple similar content types

I've worked on multiple sites recently with similar content types but haven't gotten the design I'm looking to achieve. I have multiple types of content article, interview, video, gallery, blog, etc. All of these models have very similar properties (title, slug, body, pub_date, etc). And since I'm using django and the admin, almost all ...

Creating music library database that is easily updatable

I am writing a music player for the sake of learning. I am not sure how to design the database part of it (I want to create it myself, not use some version of MySQL). My best idea so far is to create a "song" class, with filename, title, artist, album, etc. variables. Then I would have an array of "songs". This works well enough, but whe...

Database Design: Composite key vs one column primary key

A web application I am working on has encountered an unexpected 'bug' - The database of the app has two tables (among many others) called 'States' and 'Cities'. 'States' table fields: ------------------------------------------- idStates | State | Lat | Long ------------------------------------------- 'idStates' is an auto...

SQL design for various data types

I need to store data in a SQL Server 2008 database from various data sources with different data types. Data types allowed are: Bit, Numeric (1, 2 or 4 bytes), Real and String. There is going to be a value, a timestamp, a FK to the item of which the value belongs and some other information for the data stored. The most important points...

Visio data model diagram to db.

I have created my db data model diagram using Visio. Is there a way to generate the DB schema from the Visio? Appreciate your response! ...

DB design : save different details of payment (credit or check)

my question is: i have a member that can pay in 3 different way credit card check transfer from bank account how design the table that contain the history of payment. the fields of every way is different . if i save all in one table , i have lot of blank field ? what the right way to deal it ? ...

How do you determine what should be a primary key?

It's fairly general question, but I'd like to know what do you use in determination of primary key of the table. Examples supplied with you reasoning are highly desired. I noticed that many programmers add ID column and use it as a primary key. I think, it is flawed from design point of view, as ID in that case HAS NOTHING TO DO WITH T...

How to design SQL tables to allow for multiple parent table options?

Looking into creating a series of tables in a reporting hierarchy and am more or less drawing a blank. While tables in this structure can only have one parent, how do I structure the fields so that they point to the right parent table? As you'll see in my example below, a row's parent table can differ. ARRANGEMENT ...

Understanding SQL REFERENCES

Recently I've asked a question about the best way to go to design a DB schema to support multiple types of users and interactions between them, one of the answers suggested that I use one table for each user type and Distributed Keys. The thing is the only databases I actively work with are MySQL and SQLite and I've always done this kin...

Partition by Date and PK

I am designing a new laboratory database. My primary data tables will have at least id (PK NUMBER) and created_on (DATE). Also, for any two entries, the entry with a higher id will have a later created_on date. I plan to partition by created_on to increase performance on recently entered data. Since the columns increase together, t...

Enumerations in the database and O/RM

Suppose I want entries in the table Regions to have a type, e.g. a city, a country etc. What's the accepted way of storing this type, assuming I'll be using O/RM (NHibernate in my case) ? I see two options: Have an enum in the C# bussines layer with the types and store the type as a tinyint in the table. Have a lookup table RegionType...

Inheritance in Database Design

I am designing a new laboratory database with MANY types of my main entities. The table for each entity will hold fields common to ALL types of that entity (entity_id, created_on, created_by, etc). I will then use concrete inheritance (separate table for each unique set of attributes) to store all remaining fields. I believe that this...

Implement a unique page view counter?

I want to implement a user-facing view counter (similar to what SO has for question views) that tracks the number of unique views to a page. There are a couple of similar questions here but none seem to answer my question fully. What would be the best setup for this (in terms of database tables etc.)? Would it be good to add a 'views' ...

Model for localizable attribute values in Core Data Entity?

If I want to create a entity in Core Data that has attributes with values that should be localizable I'm wondering how the most efficient way would look like? As a example let's assume the following structure: Book name (localizable) description (localizable) author An localized book entry would look like this: name: ...

Design Considerations for Employees vs. Users

I'm busy with a redesign of a telephony management system, where just one example of shocking design was storing employee information in the phone extensions table. I have done many normalisations like this, factoring out employee information, but I am now faced with the decision of whether to factor 'system user' information, such as a...

Implementing Version Control of DB Objects

I will soon be beginning work on a project that (from the spec) reminds me a bit of StackOverflow. Basically, its a web app that has user-controlled content. One of the features that's got me going around in circles in my mind is the version control. Here on StackOverflow, each question and answer can have multiple revisions. This is pr...

Using a natural key, or using surrogate keys and audit table(s) for auditing/change log.

Hi all, My first question on here so be nice! I am a junior developer with not much experience and am having trouble with this problem. I have a table which needs to be auditable. Let's say this table records phone calls made by a call centre (it's not, but it's just an example). I'll call it "CallHistory". I had originally planned to...