﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 General Discussion  / Is this normalized? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 13:37:25 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Is this normalized?</title><link>http://www.sqlservercentral.com/Forums/Topic761400-149-1.aspx</link><description>thanks everyone for your very helpful tips and advice. I guess my basic normalization training is still alive and kicking.  :)</description><pubDate>Wed, 29 Jul 2009 16:33:03 GMT</pubDate><dc:creator>Layne-812700</dc:creator></item><item><title>RE: Is this normalized?</title><link>http://www.sqlservercentral.com/Forums/Topic761400-149-1.aspx</link><description>[quote][b]steveb (7/29/2009)[/b][hr]You seem to have a perfectly good natural key in the Student Table of StudentNo,  but you have added a column xId to act as the identity column.  Is this because StudentNo is not unique?[/quote]Yeah, I guess I might as well drop the xID because it defeats the purpose of the StudentNo being unique. Thanks</description><pubDate>Wed, 29 Jul 2009 15:47:31 GMT</pubDate><dc:creator>Layne-812700</dc:creator></item><item><title>RE: Is this normalized?</title><link>http://www.sqlservercentral.com/Forums/Topic761400-149-1.aspx</link><description>Noticed that the ClassCode values have a slash in the same position which may indicate that the column can be decomposed, such as the values before the slash indicate the department and after the slash, a unique value within the department.  If so, then there should be two columns.  Another ways of determining if this is a compound column is to search for a query that has "where ClassCode like '123456/%' ".  Also look for another table that has a candidate key that matches the values before the slash.Insert xClass values ('123456/12','Research')Insert xClass values ('678910/13','Technology')Insert xClass values ('123456/13','Crime')Insert xClass values ('123456/14','Business')Insert xClass values ('123456/15','Accounting')</description><pubDate>Wed, 29 Jul 2009 11:38:01 GMT</pubDate><dc:creator>Carl Federl</dc:creator></item><item><title>RE: Is this normalized?</title><link>http://www.sqlservercentral.com/Forums/Topic761400-149-1.aspx</link><description>In addition to what everyone else has said, I would also tighten up your use of NULLs.  Setting your columns up as NOT NULL by default is a good practice to have.  Not that using NOT NULL moves your tables into a new normal form, but it does help identify possible normalization areas.  I've seen, too often, developers using NULLable columns in tables because not all rows in the table use that column.  This type of use of NULLs usually means that the entity is not normalized because you've got a number of columns that don't depend on the key.  It does not look like this is the case for your tables, but a good practice is to always start off with columns defined as NOT NULL and only change it if there is a good business reason to allow NULL values in that column.</description><pubDate>Wed, 29 Jul 2009 11:26:26 GMT</pubDate><dc:creator>John Rowan</dc:creator></item><item><title>RE: Is this normalized?</title><link>http://www.sqlservercentral.com/Forums/Topic761400-149-1.aspx</link><description>I would say that it is normalized, although I would have FirstName and LastName columns instead of just a StudentName.I would also echo SteveB's response about the identity columns.  If you aren't using them as foreign keys and if the other columns (StudentNo, ClassCd, etc...) are unique, which they have to be to be used a foreign keys, I would make them the primary key and eliminate the identity column(s).</description><pubDate>Wed, 29 Jul 2009 09:54:39 GMT</pubDate><dc:creator>  Jack Corbett</dc:creator></item><item><title>RE: Is this normalized?</title><link>http://www.sqlservercentral.com/Forums/Topic761400-149-1.aspx</link><description>You seem to have a perfectly good natural key in the Student Table of StudentNo,  but you have added a column xId to act as the identity column.  Is this because StudentNo is not unique?</description><pubDate>Wed, 29 Jul 2009 06:35:57 GMT</pubDate><dc:creator>steveb. </dc:creator></item><item><title>RE: Is this normalized?</title><link>http://www.sqlservercentral.com/Forums/Topic761400-149-1.aspx</link><description>It seems to be OK. Only need is to generate links</description><pubDate>Wed, 29 Jul 2009 05:40:42 GMT</pubDate><dc:creator>shamassaeedmr</dc:creator></item><item><title>Is this normalized?</title><link>http://www.sqlservercentral.com/Forums/Topic761400-149-1.aspx</link><description>I'm trying to help a friend but it's been ages since I last took up my DB normalization course. Have I done the right thing by designing the tables as such, or can you point out if I've created less or more than enough? Thanks--student tablecreate table xStudent(xID INT identity(1,1),studentNo char(7) null,studentName char(100) null)insert xStudent Values ('0315288','Sam Asiata')insert xStudent Values ('0315289','John Doe')insert xStudent Values ('0515111','Mike Jordan')--class tablecreate table xClass(xClassID INT identity(1,1),ClassCode char(10) null,ClassName char(17) null)Insert xClass values ('123456/12','Research')Insert xClass values ('678910/13','Technology')Insert xClass values ('123456/13','Crime')Insert xClass values ('123456/14','Business')Insert xClass values ('123456/15','Accounting')--Tutorial table (1 to 12)create table xTutorial(xTutId INT identity(1,1),TutorialCd char(10) null,TutorialName char(17) null)Insert xTutorial values ('Tutor1','Tutorial 1')Insert xTutorial values ('Tutor2','Tutorial 2')Insert xTutorial values ('Tutor3','Tutorial 3')Insert xTutorial values ('Tutor4','Tutorial 4')Insert xTutorial values ('Tutor5','Tutorial 5')--Student - Class link, to get the classes belonging to a particular studentcreate table xStudClass(xTutId INT identity(1,1),StudentNo char(7) null,ClassCode char(10) null)Insert xStudClass values ('0315288','123456/12')Insert xStudClass values ('0315288','123456/13')Insert xStudClass values ('0315288','123456/14')Insert xStudClass values ('0315289','123456/14')Insert xStudClass values ('0315289','123456/12')--Link between Tutorial and Classes, to count the number of tutorial for each class/studentcreate table xTutorClass(xTutClassId INT identity(1,1),TutorialCd char(10) null,ClassCode char(10) null,xID INT null)Insert xTutorClass Values ('Tutor2','123456/12',1)Insert xTutorClass Values ('Tutor3','123456/12',1)Insert xTutorClass Values ('Tutor5','123456/12',1)Insert xTutorClass Values ('Tutor5','123456/12',2)Insert xTutorClass Values ('Tutor2','123456/12',2)Insert xTutorClass Values ('Tutor5','123456/14',2)Insert xTutorClass Values ('Tutor5','123456/13',3)select * from xClassselect * from xTutorialselect * from xStudentselect * from xStudClassselect * from xTutorClass order by 3--This is to generate countselect b.studentNo, b.StudentName, a.classCode, c.ClassName, count(*) as TutorCountfrom xTutorClass a INNER JOIN xStudent b ON a.xID = b.xIDINNER JOIN xClass c ON a.ClassCode = c.ClassCodegroup by b.StudentNo, b.StudentName, a.ClassCode, c.ClassName</description><pubDate>Wed, 29 Jul 2009 05:33:23 GMT</pubDate><dc:creator>Layne-812700</dc:creator></item></channel></rss>