database-design

DB Table Optimization join vs repeat columns

This is more of a preference but I was wondering what people think would be the optimal option to perform. I have a Question, Answer, and Point (because I need to track which user made the point) Table Dump Question: id title Answer: id question_id user_id response Point_Answer: id answer_id user_id points So in...

Dynamic Tables?

Hello, I have a database that has different grades per course (i.e. three homeworks for Course 1, two homeworks for Course 2, ... ,Course N with M homeworks). How should I handle this as far as database design goes? CourseID HW1 HW2 HW3 1 100 99 100 2 100 75 NULL EDIT I guess I need to rephrase my question. As of r...

Foreign key relationship within tables in a distributed configuration

The schemas are same on all servers. The data of respective server should not be on another but there are some relations having foreign keys to data which is not on current server currently its not possible to implement foreign key constrains across servers "then how is it handled in a distributed database architecture!? (there are f...

Determining row changes since last access in SQL Server

We have a multiuser system with users saving to a central SQL Server 2005 database. We have encountered an issue where a user refreshes in changes from the db while another user saves new data. The way we are currently collecting the changes is we have a timestamp column on each table which is filled at every row insert/update. Another u...

Primary Key and ER models

Say i have an ER model _____________ | E2 | |_____________| | | | | | | A21* A22 A23* where the A21 and A23 are primary keys. Would this mean the primary key for E2 will be PRIMARY KEY(A21, A23)? If so, then what is the difference of the diagram below. _____________ | E2 | |_____________| | ...

Database Design help needed

I am trying to develop a database model for a recruitment website and I have a lot of confusions. Job seeker can make 5 resumes online. In location field he can add 5 locations at most. Job seeker can fill up a form and jobs will be emailed according to the fields that he filled up. In this form he can select as many locations as he wa...

database design - table normalization

I want to allow users to create their resume online. Resume creation will have some steps. After first step resume will be saved. He can input data for other steps later on or he can move to next step after first step. Step 1 Personal Info: title name address phone email step 2 Employment History: career objective Recent position Prev...

varchar() primary key or int primary key?

Hi Guys, I have a problem with MySql primary keys, it's for my project i'm working on now! i have to have a unit name(not a number)as a key in my database, it is a combination of letters and numbers, i can't use any primary key in INT type, where it increments as usual! what is better? should i stick to old INT, auto increment way? ...

Is there a DB/ORM pattern for attributes?

i want to create an object with different key-value as attributes, for example: animal id name attribute id name and mapping animal_attribute animal_id attribute_id so i can have a entry "duck", which has multiple attribute "flying", "swimming", etc. Each attribute type would have its own table defining so...

What is the best database design for thousand rows

I'm about to start a Database Design that will simply manage users under companies. Each company will have a admin area that can manage users Each company will have around 25.000 users Client believes to have around 50 companies to start My main question is Should I create tables based on Companies? like users_company_0001 users_co...

Database Schema for multiple authentications, Facebook Connect, Twitter, OpenID, etc

I am building an application that I want to interface with Facebook Connect, Twitter, OpenID, and potentially other social networks. Users will be able to login using any number of these methods at the same time. My application uses MySQL as a backend database. Can someone give me guidance on what my db schema should look like for cap...

Can a database support "Atomicity" but not "Consistency" or vice-versa?

I am reading about ACID properties of a database. Atomicity and Consistency seem to be very closely related. I am wondering if there are any scenarios where we need to just support Atomicity but not Consistency or vice-versa. An example would really help! ...

What is the difference between Primary Key and unique key constraint?

What is the difference between Primary key And unique Key constraint? What's the use of it?? ...

Database structure for modelling one-way follower system like Twitter

Would this be the ideal/most optimal way to implement a one-way 'following' relationship? I have 2 tables as follows Table1: User_Info_Table UserID Name JoinDate Table2: User_Follower_Table FollowerID FollowingID Status FollowerID and FollowingID are FK constraints to the User_Info_Table UserID column The following ...

MySQL NDBCLUSTER: is it good for large scale solutions?

Hi folks, one question about NDBCLUSTER. I inherited the writing of a web site basing on NDBCLUSTER 5.1 solution (LAMP platform). Unfortunately, who designed the former solution didn't realize that this database engine has strong limits. One, the maximum number of fields a table can have is 128. The former programmer conceived tables ...

How do you merge tables with autonumber primary keys?

I suppose everyone runs into this problem once in a while: you have two tables that have autonumber primary keys that need to be merged. There are many good reasons why autonumber primary keys are used in favour of say application-generated keys, but merging with other tables must be one of the biggest drawbacks. Some problems that aris...

.net Extendable data layer...ideas please

This may be an impossible question - but if anyone has any ideas, even if it's a bespokely written solution We're trying to come up with an idea for a simple program to send out to people, backed by a database. At a simplistic level, there will be a "User" object, which just has name and email. The program just allows someone to edit ...

SQL Architecture: Is this a justified case to have only one table storing multiple entity types? (using a self JOIN)

I rarely come across a situation where a single table for multiple entity types seems better than one table per entity type. Here's an example that makes sense to me, but academically it seems wrong. QUESTION: Can I do this and still have a "sound" architecture? Example Follows Suppose two entity types, a corporation and a person. A c...

Database Design - How to enforce a foreign key constraint on a table with a Surrogate Key

My table schema is something like this 1. Master table : Clause Columns ClauseID = surrogate pk (identity) ClauseCode = nvarchar user specified value Class = nvarchar FK to a master class table etc... ClauseCode + Class = candidate key for this table 2. Master table : GroupClause Columns GroupClauseID = surrogate pk (identi...

Many to many relationship in erd

I am creating database for entertainment application. In this movies,video songs,mp3 songs like entities are included. In this movie & actors,actresses,music directors,male singers, female singers have many to many relationships. i.e. an actor works in zero or many movies & a movie includes one or many actors. so my question is how to ma...