database-design

Basic database design about intermediate optional models

I'm working on a project in which I'm having slight difficulties coming up with the design for a seemingly very simple scenario: user belongs to city which belongs to country, however, the city reference may be null while user must belong to a country nevertheless. In other words (in basic RoR model syntax), # class User < ActiveRecord...

Storing Schedule in Database

How do i store routine or schedule in Database in efficient way.Such as i have 20 rooms and in this rooms 8-10,10-12,... this way classes are held.How do i store this sort of schedule in database in efficient way? ...

In RoR, if I say that A has_one B, is it mandatory that A has one B?

I need to setup a relationship so that A has one B, but there will be some entries where A doesn't have a B. Is this possible? If not, how can this be done? Thanks for reading. ...

Design Database - better approach

Hi I have a table Costumers and another CostumersPayments. In CostumersPayments I have the type of payments (MB, Visa, so on). My problem is that each customer can have more than one payment, so I can't create a field called "IDPayment" where I set the ID of that payment, and I don't know how many payments I'll have (the administrator...

How to manage User Roles in a Database?

Hi all, I'm creating a website in which I will be managing users and their permissions. I am looking to implement user roles, and can't seem to wrap my head around how things should work. I want to be able to assign a user a certain role, and have each role contain one to several permissions that can be read easily by my script. Just wa...

Database/Schema design question regarding updates to items_for_sale over time

I understand the obvious answer to my question is: "it depends". With that out of the way, I'm hoping one (or more) of you will help me see common ways to approach this... I'm designing a database of widgets for sale. Over time the prices for each item will inevitably change. My question is should we be tracking these changes and if so,...

Optimizing queries for a database using SQL/XML. Suggested resources?

This question is theoretical as well as practical. Any results indicating useful resources on optimizing queries will be appreciated. There is a large SQL database which stores a large amount of data stored in SQLXML fields. Querying the XML directly is not fast enough. I have looked at some MSDN articles on optimizing SQLXML (i.e....

Database design with millions of entry

Suppose there is a messaging system. This system has millions of entry to be sent and get reported and the count is growing by 100K every hour. 2 service accesses db, one is sender, one is reporter. So what would you suggest in order to get maximum performance? How could the db be designed? Also what open source RDBMS would you suggest ...

SVN Database Design

Hi all, I'm looking for the database Design ( Relational - Model ) used by Subversion. I'm working in a project that should be able to merge, version and any other similar subversion operations. Does anyone know any site that describes the Subversion tables ? Thanks in advance ! ...

Question about Database structure

I am creating a simple customer support tracking system with PHP/MySQL Fuctions are followings. An admin can CRUD an customer. An admin can add points/credits.: 60points (60min) etc An admin can enter the work details, date, time duration, points and display these and point(time) remaining. The question is how to structure the table...

open source data base to handle 10 k transactions per sec?

I am trying to design data base to store 1 terabyte of data, that is able to handle 10K transactions per second I would like to use open source.What kind of architecture i can use.I am new to database(its read/write operation).Please give hints regarding this. ...

How could I design this database scenario?

I am trying to create a "Task" schema in my database. One field is "blockedBy" which represents another Task that is blocking this current task. I am new to SQL Server and databases in general. How can I create the table properly? It seems like the only valid options are numbers or text. Should I just store the ID number of the other ...

Is it OK to use "semantically reversed" associations, like Message blongsTo Attachment, in CakePHP?

Suppose that we have the following partial ER diagram: Notice that the attachments table will subsequently be used for the messages', submissions', assignments', and lectures' attachments. The problem is with the 3 one-to-one relationships between attachments and messages, submissions, and assignments. According to CakePHP's conventi...

Database: Multiple tables or just one table?

For example I have photos and videos tables, I can comment on these, but when I send it to database which way is better? To have 2 tables for comments: photo_comments and video_comments Or to have 1 table comments and create a row inside the table like type and put there if it's a photo_comment or video_comment I think the 1 is faste...

Database design for storing food recipes

I want to make a database of recipes that I like, but I'm having trouble designing it. I want to have at least two tables: Recipe table (Has description, ingredients, directions, etc...) Ingredients table (ingredient type, other attributes, etc...) What would be a way to associate a the two tables together? Would I need a third table...

Database design for items that have restricted shipping regions

I am designing the database for a shopping cart and I am having trouble deciding which way to approach this problem. There are three tiers that can items can be restricted to: 1) Local Delivery Only 2) Shipping Available a) Country b) State c) Region I am thinking to go with a structure like this: product_shipping_res...

When create new Database

I have a general Database Design question: When is it better to create a new Database instead of adding new Tables to an existing? The question is related to design/maintainability andalso performance issues. Background: we are mirroring the main tables of our customer by importing the data every night into our DB called RM2. Some new (...

How would you implement twitter using a noSQL kind of DB?

It seems like implementing web-app like twitter/facebook-wall needs 1 huge "feeds" relational table (+ a user table) and an awesome caching mechanism.. ( can you recommend one? ) my main question is, how would you implement such a "feature" using a non-relational DB, e.g. a key/value kind of DB? Obviously, I had like to support the amo...

Database normalization design - single or multiple tables

Should this be represented in the database as 1 table or 3 tables? I and my friend have different opinions about this so I'd like to see the general views on this. (Maybe it should be a vote for either solution?) Create Table Order // Basic fields of the table - ID (Primary key) - CustomerID (integer, with a FK) - Quantity - Prod...

Unique index by 3 text fields

I need to store reviews from different sources in table. Fields: 'produtcId' char(14) 'user' varchar(128) 'Source' varchar(128) 'content' text` Use cases: Find all reviews for product Insert or update review I have troubles with case 2, because I need to find if review already exist (review with same produtcId,user and Source). ...