473,396 Members | 1,599 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,396 software developers and data experts.

Normalizing a database for the first time.

Hi, I've been teaching myself how to normalize. I know I still have some things to do (tables for phones), but I'm just wondering if I'm on the right track? Thanks.

How does my 1NF database look so far? I welcome any suggestions. Thank you.

PK Person ID
Person First Name
Person Last Name
Person Street
Person City
Person State
Person Zip Code
Person Country
Person SSN
Person Marital Status
Person DOB

FK Person ID

Phone Numbers
Type


FK Person ID
PK Spouse ID
Spouse First Name
Spouse Last Name
Spouse Street
Spouse City
Spouse State
Spouse Zip Code
Spouse Country
Spouse SSN
Spouse DOB
Spouse Marital Status

PK Person ID
PK Spouse ID
Child ID
Child First Name
Child Last Name
Child Street
Child City
Child State
Child Zip Code
Child Country
Child SSN
Child DOB
Child Marital Status

FK Person ID
Vehicle Make
Vehicle Model
Vehicle Year
Vehicle Color
Vehicle Mileage
Vehicle Body Type
PK Vehicle ID

PK Vehicle ID
Vehicle Repair Date
Vehicle Repair Description
Vehicle Repair Cost
PK Vehicle Repair ID

PK Vehicle Repair ID
Vehicle Repair Shop Name
Vehicle Repair Shop Street
Vehicle Repair Shop City
Vehicle Repair Shop State
Vehicle Repair Shop Zip Code
Vehicle Repair Shop Country
FK Repair Shop ID

PK Repair Shop ID
Repair Shop Phone Numbers
Repair Shop Owner First Name
Repair Shop Owner Last Name
Repair Shop Owner Street
Repair Shop Owner City
Repair Shop Owner State
Repair Shop Owner Zip Code
Repair Shop Owner Country
Repair Shop Owner Phone Numbers
Apr 24 '16 #1

✓ answered by PhilOfWalton

Without wishing to be rude you asked how it looks - horrible - I jest.
I good guide to normalisation is to see how often the same piece of data is going to appear. So for example addresses are going to be duplicated, triplicated etc. depending on the size of the family.
A second point is that a table should roughly contain information of a similar type, so with with your persons table, names, age, sex, hair colour, marital status all apply to a person. These items are "locked" to that person. Their address changes when they move home.

So a simple example: In the case of your families, I'm guessing that many of the children live at the same address as the parents, so the address only needs to be entered once.
Now do we need a complete address? How often does the same City appear in the addresses? Once you have defined a City, you know what State it is in.
The remarks about addresses apply equally to the repair shops.
So to give you a start:
TblStates
StateID PK
State No duplicates

TblCities
CityID PK
City
StateID FK

TblAddress
AddressID PK
AddressLine1
AddressLine2
AddressLine3
CityID FK

So at this point, once you have entered the city, the state comes up automatically.

TblStatus
StatusID PK
Status (No duplicates) - Head, Spouse, Son, Daughter, Granny etc.

TblPerson
PersonID PK
PersonFirstName
PersonLastName
PersonMaritalStatus
PersonDOB
StatusID Fk
PersonHeadID FK
AddressID FK

So here's the critical bit. If you set PersonHeadID = PersonID, then that is equivalent to your Person Table. Let's be terribly politically incorrect and call this person the "Head of House"
Your Spouse and Children tables just set the PersonHeadID = PersonID (of the Head of House). The StatusID defines what relationship that person has to the "Head of House"

One further point. I strongly advise you not to have spaces in field names. If you do, you will always have to put square brackets[] round them, as Access has no way of knowing when a field name ends. so [Person First Name]
Alternatives are
Person_First_Name
or PersonFirstName.
I personally prefer the latter.

Hopes this gets you stated

Phil

5 967
PhilOfWalton
1,430 Expert 1GB
Without wishing to be rude you asked how it looks - horrible - I jest.
I good guide to normalisation is to see how often the same piece of data is going to appear. So for example addresses are going to be duplicated, triplicated etc. depending on the size of the family.
A second point is that a table should roughly contain information of a similar type, so with with your persons table, names, age, sex, hair colour, marital status all apply to a person. These items are "locked" to that person. Their address changes when they move home.

So a simple example: In the case of your families, I'm guessing that many of the children live at the same address as the parents, so the address only needs to be entered once.
Now do we need a complete address? How often does the same City appear in the addresses? Once you have defined a City, you know what State it is in.
The remarks about addresses apply equally to the repair shops.
So to give you a start:
TblStates
StateID PK
State No duplicates

TblCities
CityID PK
City
StateID FK

TblAddress
AddressID PK
AddressLine1
AddressLine2
AddressLine3
CityID FK

So at this point, once you have entered the city, the state comes up automatically.

TblStatus
StatusID PK
Status (No duplicates) - Head, Spouse, Son, Daughter, Granny etc.

TblPerson
PersonID PK
PersonFirstName
PersonLastName
PersonMaritalStatus
PersonDOB
StatusID Fk
PersonHeadID FK
AddressID FK

So here's the critical bit. If you set PersonHeadID = PersonID, then that is equivalent to your Person Table. Let's be terribly politically incorrect and call this person the "Head of House"
Your Spouse and Children tables just set the PersonHeadID = PersonID (of the Head of House). The StatusID defines what relationship that person has to the "Head of House"

One further point. I strongly advise you not to have spaces in field names. If you do, you will always have to put square brackets[] round them, as Access has no way of knowing when a field name ends. so [Person First Name]
Alternatives are
Person_First_Name
or PersonFirstName.
I personally prefer the latter.

Hopes this gets you stated

Phil
Apr 24 '16 #2
zmbd
5,501 Expert Mod 4TB
@ carlpoppa,
Have you read thru our insights article:
Database Normalization and Table Structures
It will help explain things.

As PhilOfWalton notes, spaces are not your friend in the long run, nor are the special characters or reserved words. IMHO, and I dare-say a few others, it is best practice when naming fields, tables, and files to avoid the use of anything other than alphanumeric characters and the underscore (spaces although allowed are problematic from a programing point of view and best avoided) and it is VERY important to avoid all reserved words and tokens:
Access 2007 reserved words and symbols
AllenBrowne- Problem names and reserved words in Access
Apr 24 '16 #3
jforbes
1,107 Expert 1GB
As Phil and zmbd have metioned, it's much easier to write code without spaces in the field names than with spaces in the field names.

I would merge Person and Spouse tables into the same table and add a Foreign key for Spouse that links back to the same table. Depending on your needs you may need to add a Type field to determine if it is a Spouse or not.

Personally, I would not have a separate PhoneNumber Table. I would create three PhoneNumbers fields in the Person table along with three PhoneType fields and default the PhoneTypes to Cell. This will make entering, displaying, and reporting data much easier as you won't have to Link to an additional table.

Lastly, unless I'm misunderstanding what it is that you are doing, I think the Vehicle, VehicleRepair and RepairShop tables are messed up a bit. I think you will want something like this, where there's a Vehicle Table and a RepairShop Table and then a VehicleRepair Table that links the two tables together:
Expand|Select|Wrap|Line Numbers
  1. Vehicle
  2. VehicleID (PK) 
  3. Make
  4. Model
  5. Year
Expand|Select|Wrap|Line Numbers
  1. RepairShop
  2. RepairShopID (PK)
  3. ShopName
  4. Address1
  5. Address2
  6. City
  7. State
  8. ZipCode
Expand|Select|Wrap|Line Numbers
  1. VehicleRepair
  2. VehicleRepairID (PK)
  3. VehicleID (FK)
  4. RepairShopID (FK)
  5. RepairDate
  6. Description
  7. Cost
Apr 25 '16 #4
PhilOfWalton
1,430 Expert 1GB
Sorry to disagree with you, jforbes.
Firstly I think (as indicated) that Person, Spouse & Child table should all be one table. The only difference between the three groups is their status (Head, Spouse, Son, Daughter Grandmother, etc) and who is the head of that group.
Secondly I see no reason for the RepairShop table. It's just an address. You may want a table of
Expand|Select|Wrap|Line Numbers
  1. AddressTypes
  2.     AddressTypeID
  3.     AddressType   (Main Home, Holiday Home, Repair shop etc)
  4.  
and obviously a suitable FK AddressTypeID in the address table.
This would then give carlpoppa the option to hold multiple addresses for each person using a join table.

Phil
Apr 25 '16 #5
Thanks to everyone for the information. You all have definitely helped me understand this a lot better now.
Apr 26 '16 #6

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

Similar topics

1
by: Steve Bishop | last post by:
I have an application that uses data access that runs slow the first time. My first page reads data from an ODBC source and the second page hits a MSDE database. After each page opens the first...
16
by: TB | last post by:
Hi all: If you think that the following comments are absolute amateurish, then please bear with me, or simply skip this thread. A couple of months back I made the decision to initiate a...
2
by: bwhite | last post by:
I have an access database application that is used to calculate landed costs for foreign goods imported into vartious countries. I am trying to determine an approach so that a user will be...
0
by: Massimiliano Campagnoli | last post by:
I am trying to backup sample database to network drive J:\ which maps to a SAMBA share. The first time the backup is successfull but the the next time fails. I've to delete J:\sample.0 if I want...
2
by: majestic12 | last post by:
This is the first time I've tried to use mysql/phpmyadmin and I'm having trouble. I'm using a geocites pro account and I got both installed and it set up a database call mysql and the user yroot. ...
16
by: phpmel | last post by:
Hi again, I tried this Ajax database thing for the first time and it is not working. Here is the code this is testAjax.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1
by: mrutyunjaya | last post by:
when i used this code when i running second time from xml file it shows that testdbo.xml used by another user //StreamWriter xmlDoc = new StreamWriter(Server.MapPath("~/Testdo.xml"), false); ...
7
by: ArizonaJohn | last post by:
Hello, On my site, a user enters a value into a form, and if that value is not in my database, the code below is meant to give the user the message "The topic "value" has not been added. Add the...
0
by: KishorDhembare | last post by:
Hi Everybady I Want To Create New Database When My Application Starts First Time My Application Developed In Vb.net I Get The Error When I Run Command which I Have Command Is Like. Dim...
1
by: dougancil | last post by:
I'm creating a datatable for the first time and I'm having some difficulties. I have the following code: Protected Function Dataparse(ByVal Save As String) As String Dim DataSet ds =...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
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.