Any DB gurus in here? Need someone to critique this datamodel for me.

thereds

Diamond Member
Apr 4, 2000
7,888
0
0
Any tips on normalisation would help.

It is a pretty simple datamodel - but I'm wondering if I'm missing anything.

datamodel.jpg - minor change - the commission table does have an employee foreign key
 

RichieZ

Diamond Member
Jun 1, 2000
6,549
37
91
Originally posted by: PricklyPete
Originally posted by: 777php
the employee table and the commission table do not share a primary index.

bingo...777php beat me too it.

exaclty, how are you going to join them to figure out which comission belongs to which employee
 

ndee

Lifer
Jul 18, 2000
12,680
1
0
doesn't the employee need to be linked to the tv sales? How are the comissions handled? Does a different employee maybe get a better comission than another one?
 

cyclistca

Platinum Member
Dec 5, 2000
2,886
11
81
Why are you storing qty sold in the TV_SALES table you should be able to calculate that? It depends I supose whether the "TV" table represents individual units or not.
 

Ameesh

Lifer
Apr 3, 2001
23,686
0
0
you need to add a foriegn key to the commisions table to index what employee got the sale.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
As others have mentioned, there should be an ENO column in the COMMISSION table and a foreign key to the Employee table through it.

Also, if you want to restrict the values of EMPCATEGORY to a set of known employee categories, then you might consider having a table that lists those out and a foreign key constraint from EMPCATEGORY to that table. An additional benefit is that you have a single clean list of all employee categories. By the way, what is an employee category? Is it something like Sales vs Marketing, etc? Or is it more analogous to job title? "Category" is a little too generic for my tastes.

You might consider changing the relationship between the TV_SALES table and the TV table. As things are modeled now, you record only a single kind of TV in a single sale. If you wanted to record the sale of two different kinds of TVs, you would end up with two sales records and two commissions, even if it's logically just a single sale. You could change the model by introducing a table in between the TV_SALES and TV that contains the line items. The TV_SALES table would represent the entire sale. The intermediate table (TV_SALES_LINEITEM) would represent each line item on the sale and it would reference the unit purchased and the quantity.

Do you need to support partial payments of commissions? Would you record any additional information about the payment other than the date it was paid? For instance, you might record a check number of something. If so, you could split out that information into a different table. The COMMISSION table would record what commission should have been generated from the sale. A PAYMENT table could record how that commission was paid, and it could also be used if you had to pay your employees for other things. The COMMISSION table would contain a nullable PAYMENT_ID that refers to a record in the PAYMENT table.
 

thereds

Diamond Member
Apr 4, 2000
7,888
0
0
oops I'm sorry. The commission table does have the employee foreign key but i forgot to put it in my diagram.

thanks for your help oog.

anything else I need to look for?
 

thereds

Diamond Member
Apr 4, 2000
7,888
0
0
You might consider changing the relationship between the TV_SALES table and the TV table. As things are modeled now, you record only a single kind of TV in a single sale. If you wanted to record the sale of two different kinds of TVs, you would end up with two sales records and two commissions, even if it's logically just a single sale. You could change the model by introducing a table in between the TV_SALES and TV that contains the line items. The TV_SALES table would represent the entire sale. The intermediate table (TV_SALES_LINEITEM) would represent each line item on the sale and it would reference the unit purchased and the quantity.

I'm not sure if what you said works. I can record more than one TV Sale under one payment number. The TV_Sales table holds multiple tv sales under one sale.

example -
COMMISSION TABLE
CPAYNO - 1

TV SALES TABLE
CPAYNO - 1
TVNO - 21
CPAYNO - 1
TVNO - 31
CPAYNO - 1
TVNO - 41


A category is a basic 'C1', 'C2', 'C3', which determines an employees commission rate.