database-design

sql db design retrieving and submitting nominal values

I have a simple table with autoincrementing ID's and one text column. id(int), value(nvarchar) In another User table I have this ID as a foreign key. When i retrieve datat using Linq to Sql, I get the text value of the associated ID in one simple call. What about when I need to save into the User table when i only have the text and n...

How to ask a business user for cardinality information?

When collecting requirements from business users, I run into a point where I need to understand the cardinality between two concepts in the business user's domain. This is usually something I want to know early in the process, since it affects database design which is hard to change later. For example, the busines user may have a domai...

Data schema for complex entities - which approach is simpler

I am reviewing a database model. I need some help with a part of the model. At this stage I'm just concerned with the logical model, not the implementation. I want to adopt a best practice. Summary of problem The database is used by an app that manages legal cases for a law firm. Each case has multiple parties. (By party, I mean a...

Having instance-like behaviour in databases

Hey there everyone, Sorry for the bad title, but I have no idea how to put this in short. The Problem is the following: I have a generic item that represents a group, lets call it Car. Now this Car has attributes, that range within certain limits, lets say for example speed is between 0 and 180 for a usual Car. Imagine some more attrib...

How do you deal with design changes?

I just finished working on a project for the last couple of months. It's online and ready to go. The client is now back with what is more or less a complete rewrite of most parts of the application. A new contract has been drafted and payment made for the additional work involved. I'm wondering what would be the best way to start rework...

Database Design: Storing the primary key as a separate field in the same table

Hi, I have a table that must reference another record, but of the same table. Here's an example: Customer ******** ID ManagerID (the ID of another customer) ... I have a bad feeling about doing this. My other idea was to just have a separate table that just stored the relationship. CustomerRelationship *************** ID CustomerID ...

Role Based Access Control DB Design

This question isn't about the database design of the RBAC system itself, but rather how to use this database in conjunction with the application specific database when that web application allows its users to submit content. As it stands my RBAC should easily work for a simple back-end admin application, where staff can add and update r...

Are sharding and normalization mutually exclusive?

I ran across a comment that made me wonder: If you use a sharding approach to db scalability, does that mean the database is denormalized? Can you have a normalized, sharded database? ...

Should a value always be stored in a database using a specific unit (e.g. meters) or should the unit be settable in an additional field?

Should a value always be stored in a database using a specific unit (e.g. meters) or should the unit be settable using an additional field or table? Example 1: Unit defined as part of the field buildings ----------------------------- building_id INT date_built_utc DATE reported_area_m DOUBLE Example 2: Unit defined in anot...

Alternatives to traditional relational databases for activity streams

I'm wondering if some other non-relational database would be a good fit for activity streams - sort of like what you see on Facebook, Flickr (http://www.flickr.com/activity), etc. Right now, I'm using MySQL but it's pretty taxing (I have tens of millions of activity records) and since they are basically read-only once written and always ...

[Database design] Optimize database for search (and interpolation of search values)

Hello, I have a relatively large database tables (just under a million rows) that has mapping like this: (int, int, int, int) ----> (float, float) Not all possible int combinations map to a float pair. Here is where my knowledge of database design ends: The database size is not a concern for me, but query time is. Should I worry ab...

Best way to store muti-type field

Let's say we have a field that can be in more than one type, for instance: string or date or XML datatypes. Now we have two methods to store this in a database 1- using a string typed field + field defining type: losing "type-aware" sorting capabilities, needs casting 2- separate tables (StringValues,DateValues,Decimal,XML ...etc):a f...

Database Designing and Normalization issue

Hi friends, I have a huge access mdb file which contains a single table with 20-30 columns and over 50000 rows and i have some thing like this columns: id desc name phone email fax ab bc zxy sd country state zip ..... 1 a ab 12 fff 12 w 2 3 2 d sd 233 2 d ab 12 fff 12 s 2 3 1 d sd ...

Is it fine to copy the mediawiki database architecture to design your own wiki?

In the highscalability blog, Todd Hoff talks about the wiki architecture SO adopted (initially), crunches that followed and mentions the painful refactoring needed to get back on track. To quote: Stack Overflow copied a key part of the Wikipedia database design. This turned out to be a mistake which will need massive and pai...

Unique constraint that allows empty values in MySQL

I have a field that stores product codes. The codes are unique, but some products simply doesn't have a code. I can't invent codes because those are providers codes. Is this kind of constraint possible in MySQL? I'm a noob with stored procedures and triggers, so if the solution involves one of these, please be patient. Update: The col...

How to model and query inheritance in a hierarchy of rows in a database table?

I have a set of records, stored as XML files, where the XML files are arranged in a tree structure. For each child record, elements or attributes which are not explicitly stated are assumed to be inherited from the parent record. This is easy to model in a database, with a self-referential foreign key, e.g. Tree Structure Foo / ...

Tool for creating relational model diagrams

I'm looking for a free and simple tool for creating relational model diagrams. All that i need is to be able to draw tables and fields and connect fields that are foreign keys to their referenced tables. As an example I found this image on the net. I don't need anything more: I want to keep schema simple and clean. Thanks for your...

Developing a Highly-Configurable Banner Service

That title may need some work. Perhaps after reading this, you may be able to improve on it. The boss called me up today and informed me that a recent project we completed is now getting substantial traffic, and advertisers are starting to knock on our doors. I need to develop a method of rendering, tracking, and configuring banners for...

Designing a database for user-customized groupings

A user can search for colours and add them to their palette.. So if they write blue, blue will show up and they can add it. so on with red, yellow....... But I want, that if they choose "dark colors", then grey black and brown should be added. Today I´m doing like this if($color==darkcolor) insert black and grey and brown... Is ...

How to Insert row between two rows and give it priority in database ?

Hi everyone!. i have a stack of messages in database table. i want to send these messages by their priority so i added "Priority" column to "messages" table. but what if i want to insert "cram" message between two messages and give the previous priority to this new message?. Should i update all messages priority under this message. S...