Question

I have this table to normalize for a uni project, now every time I think it should just be two tables, I then think no it should be three... I am going to throw this out to one of you guys superior knowledge as maybe you can indicate the best way it should be done and why.

 Number Type    Single rate Double rate Family rate
1        D          56          72  
2        D          56          72  
3        T          50          72  
4        T          50          72  
5        S          48      
6        S          48      
7        S          48      
8        T          50          72  
9        T          50          72  
10       D          56          72  
11       D          56          72  
12       D          56          72  
13       D          56          72  
14       F          56          72         84
15       F          56          72         84
16       S          48      
17       S          48      
18       T          50          72  
20       D          56          72  

Many thanks for anyone that can help me to see the corret way

Was it helpful?

Solution

It is not possible to produce correct table design unless one understands exactly what the columns mean and how the data columns depend on one another. However, here is an attempt that can be refined once you provide more information for us. The used naming is not as good as I'd like it to be but as I said, the purpose is not clear in the question. Anyway, this is a start, hope it would help you. Also note that Normalization is not always required for all types of applications. For example, Business Intelligence could use schema that are deliberately not fully normalized (e.g. Star Schema). So the database design may sometimes depend on the application nature and how data change.

Main 
----
MainID                      int           PK
MainTypeID                  Char(1)       Example: D, T, S etc.
MainRateIntersectionID      Int

MainRateIntersection
--------------------
MainRateIntersectionID      int           PK
MainID                      int
RateCategoryID              int


The combination of MainID and RateCategoryID should be constrained 
using UNIQUE INDEX

RateCategory
------------
RateCategoryID              int            PK
RateCategoryText            Varchar2(15)   Not Null    Example:Single, Family, etc.
RateValue                   Int            Nullable

MainType
---------
MainTypeID      Char(1)     PK

Edit

Based on the new information, I have revised the model. I have removed the 'artificial' IDs since this is a training project for Normalization. Artificial IDs (surrogate keys) are correct to add but is not your objective as I guess. I have to add booking table that where a row would be inserted for each customer that makes a booking. You need to add appropriate customer information in that table. The table you provided is more of a logical view that could be returned form a query but not a physical table to store and update in the database. Instead, the bookings table should be used.

I hope this could help you.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top