database-design

Referential integrity in a relational data warehouse. Is it worth it? and what are the alternatives?

Hi, If you had to build a relational data warehouse of biblical proportions using SQL Server 2008, would you use foreign keys to enforce data integrity, or would you use some other means? I like foreign keys because you only need to get them right once, and they are always there to protect integrity. I was thinking of going the disable...

help in solving a problem in sql server

I have aquestions from you. Does SQL server have any features so we can limit a field to fill with just specific values? For example assume that you have a field named "Name" then we want SQL just let us to fill this field with the following values: "Bella", "Jack", "Rose". is there any featues to do it? please guide me. thanks ...

Why to use "not null primary key" in TSQL?

I am seeing too frequently "not null primary key" in scripts creating tables in TSQL in blogs, articles, books, forums, here in SO, etc. For example, BING gives 630,000 results ((just in English) if to search against "not null" NEAR "primary key" "sql server": http://www.bing.com/search?q=%22not+null%22+NEAR+%22primary+key%22+%22sql+s...

Cannot create a row of size 8937 which is greater than the allowable maximum of 8060

We are getting this error on a table in our database: "Cannot create a row of size 8937 which is greater than the allowable maximum of 8060." The table consists of about 400 varchar(max) fields. We are, however, only inserting empty strings into these fields. The insert seems to work, however when using SqlXml to read the data or whe...

NULL permitted in Primary Key - why and in which DBMS?

Subquestioning my question "Why to use “not null primary key” in TSQL?" [1] As I understood from other discussions, some RDBMS (for example, MySQL, SQLLite, which else?) permit "unique" NULL in primary key (PK). I read-read and could not grasp - why and what's for? Update: I believe it is beneficial for communication with other...

DB for Commenting System

i wanna create a 2 level status message system. Which is the best way to create a tables ? Scope: User sets a Status Message Users Reply to the status message this is a picture showing it Tables i have created users (id, name .... ) status_messages (id, message, time, user_id) status_message_replies (id, message, time, status_me...

Many-to-many relationship or not?

Hey guys 8D I'm in a bit of trouble trying to define the type of a relationship between 3 tables. They are PRODUCTS, SUPPLIERS, and the third, QUANTITY, where I have a combination of product and supplier and a field storing the quantity of products of that combination. I can have one product from one or more suppliers, that's why the t...

Database design for dynamic form field validation

In my application, I allow users to create a form containing any HTML form field they want (e.g. text input, textarea, select, etc.). I want to give the users the ability to define 0 or more cumulative validation rules for each field (there might be up to 25 different validation rules). How should I model this? Here's a potential soluti...

Database design: bigger table vs query the entity for every row in dataTable

I have a table of NewsFeed. NewsFeed + id + fromUserId + targetId + type so the news is like this: Tom Wakefield commented on Peter Smith's profile. So either I add two more fields into my NewsFeed call fromUserName and targetUserName OR For every row I display in my dataTable I would query from the Entity. <p:dataTable value="#{my...

Question on Database Design Tips

This is not a homework, but new task assign by superior. To create a system for in-house end-users, which auto suggest to different assembly line based on each line's capacity. Users need to maintain each line capacity everymonth, and each line have its own product group running on it with unique prority on each assembly line. When the...

"Warn on null primary keys" table design option in SSMS

I SSMS (2008R2) menu Tools --> Options --> Designers --> Table and Database Designers --> "Warn on null primary keys" I played checking and unchecking this checkbox but could not detect the differences. What is it for? My related questions, probably: NULL permitted in Primary Key - why and in which DBMS? Why to use “not null pr...

Design Pattern required for database schema with two classes both composing a third class.

Consider a system which has classes for both letters and people; both of these classes compose an address. When designing a database for the system it seems sensible to have a separate schema for the address but this leads to an issue; I don't know how to have a foreign key in the address table cleanly identify what it belongs to because...

Database Performance Solution - "View Caching" - Is this a good idea?

Hi, A little context first: I would say I have good SQL server experience, but am a developer, not a DBA. My current task is to improve on the performance of a database, which has been built with a very heavy reliance on views. The application is peppered with inline sql, and using Tuning Advisor only suggests a couple of missing index...

Generic Database Manager(Wrapper)

Hello to all, AFAIK, we all must programming to database through database wrapper/manager such as sqliteman or CppSQLite. But the database wrapper is specific to one type of database and this is not convenient for programmer cause require a lot of modification in case the database was cahnged. Therefore, i would like to write a gener...

How many columns in MySQL table

How many fields are OK to have in a MySQL table? I have a form to get information from users, it is divided into 6 or 7 unites, but all related to each other. They are about 100 fields. Do you recommend to keep all of them in one table? ...

problem designing database

hi, im using sql server 2008. my scenario is as follows. there is a user table, with userid, password, ....rest of the fields it is something related to insurance, the cases are as follows logged-in user is insured (there is only one person here) logged-in user is insured and there is one more insured under the same user (there are t...

Time table modeling in relational db

I know that it has been told almost anything related to time table modeling in RDBS, but i can not find any well written documentation about available techniques to store time tables in DB. My case: I have table witch holds available places, and table with actual classes. Each place has it's own unique schedule Each class can be sched...

Best way to build a DataMart from multiple external systems?

I'm in the planning stages of building a SQL Server DataMart for mail/email/SMS contact info and history. Each piece of data is located in a different external system. Because of this, email addresses do not have account numbers and SMS phone numbers do not have email addresses, etc. In other words, there isn't a shared primary key. ...

Generally, are string (or varchar) fields used as join fields?

We have two tables. The first contains a name (varchar) field. The second contains a field that references the name field from the first table. This foreign key in the second table will be repeated for every row associated with that name. Is it generally discouraged to use a varchar/string field as a join between two tables? When is t...

Database Design: replace a boolean column with a timestamp column?

Earlier I have created tables this way: create table workflow ( id number primary key, name varchar2(100 char) not null, is_finished number(1) default 0 not null, date_finished date ); Column is_finished indicates whether the workflow finished or not. Column date_finished is when the workflow was finished. Then I had ...