database-design

SQL Server: pulling and updating local data

Hi guys, I have two SQL Server 2008 databases called Anna and Bob. Bob has to pull and transform data from Anna to keep updated his tables. Ideally Bob will be always synchronized with Anna, but some delay would be acceptable. What is the best way to do this? Thanks in advance. ...

XML flat file vs. relational database backend

Most projects now need some form of a database. When someone says database, I usually think relational databases, but I still hear about flat file XML databases. What parameters do you take into consideration when deciding between a "real" database and a flat-file XML database. When should one be used over the other, and under what cir...

Getting the final value to this MySQL query...

I've got my database set up with three tables - code, tags, and code_tags for tagging posts. This will be the SQL query processed when a post is submitted. Each tag is sliced up by PHP and individually inserted using these queries. INSERT IGNORE INTO tags (tag) VALUES ('$tags[1]'); SELECT tags.id FROM tags WHERE tag = '$tags[1]' ORDER ...

is there anyway to add a primary autonumber key to an already existing database table

i have inherited a database application from someone else and there are a few tables that dont have any primary keys. I want to add a new column into an already existing table and have it autonumber (starting from 1). how would i go about doing this? ...

Understanding MongoDB (and NoSQL in general) and how to make the best use of it

Hello, I am beginning to think that my next project I am wanting to do would work better with a NoSQL solution. The project would either involve a ton of 2-column tables or a ton of dynamic queries with dynamically generated columns in a traditional SQL database. So I feel a NoSQL database would be much cleaner. I'm looking at MongoDB ...

[PHP/MySQL] How to create text diff web app

Hello, idea I would like to create a little app for myself to store ideas (the thing is - I want it to do MY WAY) database I'm thinking going simple: id - unique id of revision in database text_id - identification number of text rev_id - number of revision flags - various purposes - expl. later title - self expl. des...

What is the best way to handle validity dates in applications ?

Hello, How do we model these objects ? Scenario 1: Price changes in a time period EffectiveDate ExpiryDate Price 2009-01-01 2009-01-31 800$ 2009-02-01 Null 900$ So, if the price changes to 910$ on 2009-02-15, then the system should automatically update the expiry date on the previous effective price to 2009-0...

Storing information for drop-down menus

Suppose you're building an HTML form and you want to have 2 or more drop-down menus, where after picking an option from the first, the 2nd menu is populated, and so forth. For example, choosing a country would bring up a list of provinces for that country, which would in turn list the cities. How would you store that sort of information...

archiving strategies and limitations of data in a table

Environment: Jboss, Mysql, JPA, Hibernate Our web application will be catering to a large amount of users (~ 1,000,000) and there are a lots of child table where user specific data are stored (e.g. personal, health, forum contributions ...). What would be the best practice to archive user & user specific information. [a] Would it be...

Rails custom db table

My app is sending messages to client groups. I send message to each client in a loop. I'm using 3 ActiveRecord models: class Message < AbstractBase has_and_belongs_to_many :groups end class Client < ActiveRecord::Base has_and_belongs_to_many :groups end class Group < ActiveRecord::Base has_and_belongs_to_many :messages has_an...

How to track history of db tables that include many-to-many mapping tables?

I have seen several questions here on tracking db history, but can't seem to find one that matches our situation. We need to track the history of several tables, some of which are many-to-many linking tables. Eg say we have this schema: EntityA id name EntityB id name ABLink A_id B_id So, tracking changes to EntityA or EntityB see...

Back Orders for ERP: data model references ?

My question is: do you know of any real good reference (book, web) for ERP database design ? I have built an ERP using Sql Server as a back-end. There are different types of Client documents (there are also Supplier Docs): Order -- impact: Back-Orders (BO) Delivery Note (also used for returns, with negative quantity) --impact: B...

Can I set ignore_dup_key on for a primary key?

I have a two-column primary key on a table. I have attempted to alter it to set the ignore_dup_key to on with this command: ALTER INDEX PK_mypk on MyTable SET (IGNORE_DUP_KEY = ON); But I get this error: Cannot use index option ignore_dup_key to alter index 'PK_mypk' as it enforces a primary or unique constraint. How else should I s...

Design Help/Suggestion required

I have an Application built 4 years back, The Application generates the 1,00,000 challans every year. I am maintaining the separate table for storing the challans and I have the Challan Id(Auto Increment) and that I am using that as the Challan Number for the application. Every since i am generating the challan Number, the length of th...

Database Design Question regarding duplicate information.

I have a database that contains a history of product sales. For example the following table CREATE TABLE SalesHistoryTable ( OrderID, // Order Number Unique to all orders ProductID, // Product ID can be used as a Key to look up product info in another table Price, // Price of the product per unit at the time of the order Quantity, // q...

What is the right way to do flexible columns in database?

Im storing columns in database with users able to add and remove columns, with fake columns. How do I implement this efficiently? ...

Designing a Tag table that tells how many times it's used

Hi, all. I am trying to design a tagging system with a model like this: Tag: content = CharField creator = ForeignKey used = IntergerField It is a many-to-many relationship between tags and what's been tagged. Everytime I insert a record into the assotication table, Tag.used is incremented by one, and decremented by one in...

What is an index in MySQL?

http://i.imgur.com/JdsUK.jpg I created a table like the picture above. What are the "Indexes"? primary key? unique? It works well without setting indexes.. What do they do? why do I need them? Also, I set all String fields to TEXT because I didn't know how many characters I need. Is this a good idea? I don't see any difference. Thank...

Storage model for various user setting and attributes in database?

I'm currently trying to upgrade a user management system for one web application. This web application is used to provide remote access to various networking equipment for educational purposes. All equipment is assigned to various pods, which users can book for periods of time. The current system is very simple - just 2 user types: admi...

Storing Preferences/One-to-One Relationships in Database

What is the best way to store settings for certain objects in my database? Method one: Using a single table Table: Company {CompanyID, CompanyName, AutoEmail, AutoEmailAddress, AutoPrint, AutoPrintPrinter} Method two: Using two tables Table Company {CompanyID, COmpanyName} Table2 CompanySettings{CompanyID, utoEmail, AutoEmailAddress, A...