Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to Structure a Table?

Author  Topic 

jp2code
Posting Yak Master

175 Posts

Posted - 2009-08-27 : 16:07:12
I've got to make something for storing training classes offered here at work.

In my Visual Studio application, the training class contains a list of Employee ID numbers.

What's the best way to translate that to a table?

I don't want to add the training class number to the Employee table because ...well, that just isn't where it belongs.

Should the table entry for the particular training class have a column to accept a Comma Separated Value list of Employee IDs? This feels like a hack. That's all I can think of, but then I haven't had any classes in database design.

Looking for some ideas, please.

Thanks,
Joe


Avoid Sears Home Improvement

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-27 : 16:35:31
Something like this

Employee Table
EmployeeID int PK
Fname
Lname
etc.

Class
ClassId int PK
Desription varchar...

EmployeeClass
EmployeeId -- FK --> Employee
ClassId -- FK --> Class
Go to Top of Page

jp2code
Posting Yak Master

175 Posts

Posted - 2009-08-27 : 16:44:10
That's the idea.

Say I have a "Safety" class coming up with 18 people.

Class.ClassId = 1
Class.Description = "Safety"

[Employee Table] // has 18 different people

EmployeeClass.ClassId = 1 // OK, I've got this
EmployeeClass.EmployeeId = ??? // How do I enter the 18 people?


Avoid Sears Home Improvement
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-27 : 16:50:32
either enter them one at a time, or...

have a look at this: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210 and scroll down to "CSV / Splitting delimited lists"

Go to Top of Page

jp2code
Posting Yak Master

175 Posts

Posted - 2009-08-27 : 17:28:45
Right now, I am using a CSV list. Like I said, though, it just feels like a hack or a bad design.


Avoid Sears Home Improvement
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-28 : 00:00:29
I agree

How are the employees selected...a bunch of checkboxes in the app?

If it's something like that, I'd just run a loop in the app and do the inserts one at a time
Go to Top of Page

jp2code
Posting Yak Master

175 Posts

Posted - 2009-08-28 : 09:04:10
It (the app) hasn't been written yet. I want to get a solid theory for how to work the new tables before getting to the point where I needed them.

The Training Application will look somewhat like Google's Finance page (see http://www.google.com/finance?client=ig&q=GOOG), but certainly not as nice. :)

The timeline will show training classes, though, not news events. Clicking a training event will fill a Data Grid View control with a list of employees that have signed up for the class.

This is, of course, all in theory. Lots of development required!


Avoid Sears Home Improvement
Go to Top of Page
   

- Advertisement -