Question about Normalization (1 Viewer)

cright99

Registered User.
Local time
Tomorrow, 03:46
Joined
Jan 17, 2009
Messages
24
Im new to Normalization and working on updating my database which has about 1500 clients in it for my parents immigration company. I want to reduce the size of the database.

I have for example two tables that are

CLIENTS(ClientID, FirstName, Lastname, PermitType*, PermitLocation*)
PERMITLOOKUPS(PermitLookupID, Type, Location)

I thought to save space I should use the same table PermitLookups for both Type and Location. Is that correct or should i use different tables for each look up field?
The list of different types of permits and location is about 40 each.
 

RuralGuy

AWF VIP
Local time
Today, 09:47
Joined
Jul 2, 2005
Messages
13,826
If the PermitType is tied to the PermitLocation then you don't need two fields in the Clients table.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 16:47
Joined
Sep 12, 2006
Messages
15,686
tried to answer this earlier on, but my connection failed

here's a longer discussion

--------
its not a question of reducing the size of the database - a database is what it is

however, in general the clients table should merely store a permitlookupid, which should be the primary key of the permitlookups table, and not the other details form the permit table

whenever you need to know the permit type, and location, you then obtain these by dereferencing the pemit lookup.

however, IF the permit table has multiple locations for each permit type, then proper denormalisation might even indicate a further deconstruction of the permit table, to store the permit types separately, (and maybe the locations separately) Assuming the permit types are text, doing it this way prevents erorrs arising by bad entry of the permit type, or location data, and restricts users to entering only certain particular values.

(eg by misspelling, as this might cause you to have multiple versions of what is really the same entity)


so you MAY really need this set up

clients(client detaisl as you have them, permitlookup)

permittypes(ptypeid, ptypedesc)

permitlocations(plocid, plocdesc)

permits(permitid, ptypeid, plocid)

where the matching colours correspond to the cross-refs

Note that you certainly increased efficiency with this setup, because of the use of ids/KEYS in the lookup tables - the id's (KEYS) should generally(always) be long integer numbers.

a) size saving, as longints are smaller than text
b) speed increase, as longints are easier to handle than text
c) importantly - data independence, as you can change the description of the permit type etc WITHOUT it impacting on your database at all - since other data is not referring directly to the description, but to the index value. If you dont have this disconnection, then EVERY time you change a text value, it has to also change everywhere it is stored - now you can do this with cascading updates, but i am sure you can sense that is not a desirable feature.
 

cright99

Registered User.
Local time
Tomorrow, 03:46
Joined
Jan 17, 2009
Messages
24
Thanks a lot for that! I learnt so much from it :)

Ive just been working on the erd for the database for the last few hours.
I came up with this...

I dont expect anyone to help or suggest any improvements to it. As I realise people have lives and there is quite alot to the erd. But thought i might as well share.. Thanks so much!

(Pv means Permit/Visa.)

 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 16:47
Joined
Sep 12, 2006
Messages
15,686
might be ok - but this sort of question is germane

applicationslodged includes caseofficerid AND branchid

caeofficerid ALSO includes branchid

why store branchid in BOTH applicationslodged AND caseofficer tables
 

cright99

Registered User.
Local time
Tomorrow, 03:46
Joined
Jan 17, 2009
Messages
24
Yea good point. Im not sure how it works, ill have to ask the business.
An application can be lodged at a branch. And also a Case officer can be located at a branch which is assign to an application. Annnyway... the question has been asked. So thank you!
 

Users who are viewing this thread

Top Bottom