473,395 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Database Normalization: Related, but categorically distinct, information.

pbmods
5,821 Expert 4TB
Heya.

I'm adding features to a pre-existing project, and I was curious about the way I've been going about designing my database additions.

My methodology is to keep my stuff separate from the other guy's stuff as much as possible. That way, I know that if it breaks, it is definitely my code's fault (or at least, 85% of the time it is... who HIRES these people?!).

Likewise, on the database side, there's a pre-existing CMS in there, and I want to add additional fields.

Now, I can be reasonably sure that if I add columns to the CMS table, the other guy's CMS code will break with 'column count doesn't match value count' errors. And even if I wanted to fix that (which I don't), I'd have to start mucking around in this CMS to make sure that editing entries doesn't null out my custom fields, etc.

So I created a separate table to map a one-to-one relationship.

In pseudo-sql, we have now two tables:
Expand|Select|Wrap|Line Numbers
  1. table `CMS`
  2. (
  3.     `CmsID`    serial,
  4.     `Data`    text
  5.     .
  6.     .
  7.     .
  8.     (and so on, pretty much your everyday sub-standard CMS table goes here)
  9. )
  10.  
  11. table `CMS_Geocodes`
  12. (
  13.     `CmsID`    serial,
  14.     `Lat`    float(8,5),
  15.     `Long`    float(8,5),
  16. )
  17.  
Ok, so obviously, this is the only feasible way to do it without having to maintain the other guy's code.

But my question is in regarding to *my* projects. Should I be splitting up my data this way even when I'm maintaining the backend, or does that create too much overhead? How does this fit in with the database normalization model?

For example, suppose I had a table that looked like this:
Expand|Select|Wrap|Line Numbers
  1. table `Util_Users`
  2. (
  3.     `Username`    varchar(60) primary key,
  4.     `Password`    char(40),
  5.     `created`    timestamp,
  6.     `realname`    varchar(200),
  7.     `dob`        date,
  8.     `bio`        text
  9. )
  10.  
Would that be considered an acceptible setup, or should I do this instead:
Expand|Select|Wrap|Line Numbers
  1. table `Util_Users`
  2. (
  3.     `Username`    varchar(60) primary key,
  4.     `Password`    char(40),
  5. )
  6.  
  7. table `Util_UserProfiles`
  8. (
  9.     `Username`    varchar(60) primary key,
  10.     `created`    timestamp,
  11.     `realname`    varchar(200),
  12.     `dob`        date,
  13.     `bio`        text
  14. )
  15.  
In both cases, there is a one-to-one relationship between the primary key and its corresponding data. But in the second example, categorically distinct data is separated into its own table.

What are your thoughts on this? Should I strive to keep as much (related) data in as few tables as possible, or should I be separating stuff based on its purpose?
Jul 16 '07 #1
1 2947
MMcCarthy
14,534 Expert Mod 8TB
In both cases, there is a one-to-one relationship between the primary key and its corresponding data. But in the second example, categorically distinct data is separated into its own table.

What are your thoughts on this? Should I strive to keep as much (related) data in as few tables as possible, or should I be separating stuff based on its purpose?
Essentially columns dependent on the primary key belong in the same table and only columns dependent on the primary key. However, from a practical point of view it is sometimes appropriate to break out tables into one to one relationships. However, I would create a new primary key and have foreign key reference to the primary key of the first table.
Jul 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: mountain man | last post by:
Greetings to all database professionals and laymen, Let us make a bold assumption that we have developed a software tool for the SQL Server environment which simply acts as an interface between...
14
by: Mickey | last post by:
I have a database in which I have 2 tables. One table is Employees, other is Events. I have only one field in Employees and it is EmployeeName (text 50 chars). Events has fields AutoNumber,...
6
by: DH | last post by:
I have a VERY basic question about figuring database size. I've inherited a database which is generally similar to this basic one: Item, Red, Blue, Green, Yellow (text), (int),(int),(int),(int)...
5
by: Bob Alston | last post by:
I am looking for any Microsoft Access based software that could be used for a United Way agency that provides basic needs assistance - food, clothing, financial (rent, utilities, Rx, gasoline,...
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
6
by: No Spam Man | last post by:
Hi, I am not a programmer and in the past have only created very simple, flat file databases. Although I'm a newbie, I think I could probably figure out basic Boolean logic and financial...
10
by: shsandeep | last post by:
The ETL application loaded around 3000 rows in 14 seconds in a Development database while it took 2 hours to load in a UAT database. UAT db is partitioned. Dev db is not partitioned. the...
76
MMcCarthy
by: MMcCarthy | last post by:
Normalisation is the term used to describe how you break a file down into tables to create a database. There are 3 or 4 major steps involved known as 1NF (First Normal Form), 2NF (Second Normal...
47
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.