database-design

what's the possible solution to build a app host(such as wordpress.com or google group) in java?

Hi All, I'm wondering how wordpress.com or google group host multiple applications for different party. For wordpress, I guess it will create a subdomain for each user and configured a virtual host in Apache for this installation. Of course, a database is installed for this user (or tables with prefix). Will the wordpress application ne...

linking two different Primary Keys from one table in a second table.

I am just learning normalization, so please forgive me if this is a dumb question. I have a table TBL_Users with the Primary Key being ID. To track who is friends with who my most recent thought was to do a table with two Foreign Keys, both of which are the other person's ID. However the more I think about this I can't help but think th...

Scalable MySQL databese for mail-like messaging

Assume we have a popular site. We need to implement mail-like messaging between users. Typical solution is to use 2 tables: Users (user_id) Messages (message_id, sender_id (references user_id), receiver_id (references user_id), subject, body ). This method has 2 significant limitations All messages of all users are stored in one tab...

Do multiple foreign keys make sense?

can it make sense for one table to have multiple foreign keys? Suppose I have three tables, Table A, Table B and Table C. If I think of the tables as objects (and they are mapped to objects in my code), then both Tables A and B have a many to one relationship with Table C. I.e. Table/object A and B can each have many instances of C. ...

Database design query - how do I join these tables?

Hi, I've got the following tables in a CMS database (SQL Server 2008) for a website: SiteMap Page Link ========= ========= ========= SiteMapId PageId LinkId LeftNode Name Name RightNode UrlId Url -- etc -- -- etc -- Sitemap table contains the website hiera...

SQLite table design question

I'm working on a program that deals with invoices for services done. I'm wondering what is the best way to layout a table of invoices which can have one or more tasks for each invoice. So far the invoice consists of: Invoice Table | InvoiceNumber | Department | DateOfBilling | Now, I need to somehow store the jobs associated with that...

Many-to-many relationship with optional value?

I have a many-to-many relationship between two tables: Order and Item. I need to save an extra information on this relationship, the quantity. So, I have to create an extra table in my model .xcdatamodel? In the following schema, both orderItems are to-many relationship to OrderItem table. order & item are inverse relationship. Orde...

How do I decide whether columns should be combined in a single table or split into multiple tables?

should we always combine one-to-one tables? I have a user id uid, a table containing the basics: uid, name, address, etc.. and another table that is essentially the same thing, with the foreign key on the previous user table uid, stats, etc.. should i just combined them? when does it make sense to and when would i not want to? ...

Best way to Display/Update Derived information?

A common issue I am faced with is having derived information that must be displayed on detail pages and in overview tables. For example, there maybe a status for 1 item based on the status of multiple sub-item's status value. It seems storing the derived status for the main item would be wrong but sorting and filtering for this informat...

Should I add this new column to customers table or to a separate new table?

Hello, I have a customers table with information about our customers (ID, login, name, contacts info, different options, TS column, and so on, ~15 columns, ~few hundreds of customers). Now we need to send every-day-updates to our biggest customers (<10% of all customers). And I need to store timestamp of the latest update which were s...

If I am allowing users to vote if only they are registered users... what other problems could arise?

Suppose I am allowing users to vote only if they are registered users. I should limit each user to vote only once per article? I should maintain a table with 4 columns - articleid, userid, bit (to indicate positive/negative) and a datetime column. Do you still see this being abused? to obtain net rating, I would query the table twic...

I have a doubt in Database designing ?

We have a Sales related project. Now we are keeping the stock of the products in a separate table named Stock. At the time of sales, sales-return, purchase and purchase-return the stock table will be updated. It works well, but while we are deleting or modifying one of the sales or purchase, it's more difficult to maintain the stock. ...

Help with Primary keys and unique constraints

In a table I've got 3 columns: id tag1 tag2 id is a primary key. And i only want one unique tag1-tag2-combination in that table. eg if one entry looks like: id: 1 tag1: cat tag2: dog I dont want a second entry like this one beneath to get inserted: id: 2 tag1: cat tag2: dog So i made all 3 columns primary keys but the problem...

Should I use a unique string as a primary key or should I make it as a separate autoincrement INT?

Possible Duplicates: Surrogate Vs. Natural/Business Keys When not to use surrogate primary keys? So, I would prefer having an INT as a primary key with AI. But, here is the reason why I am considering making a unique string as a primary key: I don't have to query related tables to fetch the primary key since I will already k...

How to create "two-side" many-to-many relationships in Rails?

Suppose we have a photography site. Any author can subscribe to receive updates from any other author. Obviously if author A is subscribed to author B that doesn't mean that B is subscribed to A. So we build models class Author < ActiveRecord::Base has_many :subscriptions has_many :subscribed_by_author, :through => :subscriptions, :...

Storing Images In Filesystem As Files Or In BLOB Database Field As Binaries

Possible Duplicate: Storing Images in DB - Yea or Nay? Which approach is better? What are the advantages and disadvantages? Advantages of storing images in database, in my opinion, are: database integrity (it's easier to keep all database entries valid with foreign keys than to keep an eye on filesystem and make required ch...

Is it easy to switch from relational to non-relational databases with Rails?

Good day, I have been using Rails/Mysql for the past while but I have been hearing about Cassandra, MongoDB, CouchDB and other document-store DB/Non-relational databases. I'm planning to explore them later as they might be better alternative for scalability. I'm planning to start an application soon. Will it make a different with Rail...

Meaning of Primary Key to Microsoft SQL Server 2008

What meaning does the concept of a primary key have to the database engine of SQL Server? I don't mean the clustered/nonclustered index created on the "ID" column, i mean the constraint object "primary key". Does it matter if it exists or not? Alternatives: alter table add primary key clustered alter table create clustered index Doe...

mongodb data design question

I'm trying my first application with mongodb on Rails using mongo_mapper and I'm weighing my options on an STI model like below. It works fine, and I will of course add to this in more ways than I can currently count, I just curious if I wouldn't be better off with Embedded Documents or some such. I'd like my models to share as much as...

Doubt regarding a database design

I have a doubt regarding a database design, suppose a finance/stock software in the software, the user will be able to create orders, those orders may contain company products or third-party products typical product table: PRIMARY KEY INT productId KEY INT productcatId KEY INT supplierId VARCHAR(20) name TEXT description ... but...