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

which table design is more correct?

Hi,

I want to create a table like this:

ID Autonum
Datefld Date
Cat Text
Itm Text
tCount Number

Data would look like this:

Data would look like this:

ID Datefld Cat Itm tCount
1 1/1/03 A itm1 3
2 1/1/03 A itm2 4
....
20 1/1/03 A itm20 2
21 1/1/03 B itm1 4
22 1/1/03 B itm2 5
....
40 1/1/03 B itm20 7
....
121 1/1/03 G itm1 8
....
140 1/1/03 G itm20 14
141 1/2/03 A itm1 7
....
160 1/2/03 A itm20 16
161 1/2/03 B itm1 9
....
281 1/3/03 A itm1 22
....

There are 7 categories A, B, C,... G. Each category
contains 20 Items per day, and a count of each item in
each category for each day. Someone at my place is telling
me that the correct way to create my table to to have 2
tables Master Table, Detail Table.

The Master table would contain the ID field, Date field,
and Cat field. The Detail table would contain the ID
field, Itm field and Count field. The argument is that
each category should be listed only one time per day, and
relate to the Detail table by ID. Data would now look
like this:

Master Table
ID Datefld Cat
1 1/1/03 A
2 1/1/03 B
...
7 1/1/03 G
8 1/2/03 A

Detail Table
ID Itm tCount
1 itm1 ...
1 itm2 ...
....
1 itm20 ...
2 itm1 ...
....

This seems a little redundant to me. You have less rows
in the Master table but the same number of rows in the
Detail table as with my original plan of using just one
table. The second design contains an extra column and an
extra table and joins I would now have to deal with.

So my question is - for my purposes - just to query count of items per
category per date range (real basic queries),
which of the 2 designs described here is more
correct/practical? Any suggestions appreciated.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
5 1855
Seems to me that your friend is correct. Since you said "each Category has
20 Items per day" that tell me you have a one-to-many relationship between
the items and the categories. If you make a form for your Category info and
a linked subform for your items data, then you will only enter the data in
the Date and Category fields once for all 20 items, etc. This is the idea
of a relational database. One of the ways you can check this is to go to
the Tools.Analyze.Table feature in your MS Access database and analyze your
table. It will help you to decide. Let me know who wins.

Denny G.
"mm nn" <bb******@hotmail.com> wrote in message
news:3f***********************@news.frii.net...
Hi,

I want to create a table like this:

ID Autonum
Datefld Date
Cat Text
Itm Text
tCount Number

Data would look like this:

Data would look like this:

ID Datefld Cat Itm tCount
1 1/1/03 A itm1 3
2 1/1/03 A itm2 4
...
20 1/1/03 A itm20 2
21 1/1/03 B itm1 4
22 1/1/03 B itm2 5
...
40 1/1/03 B itm20 7
...
121 1/1/03 G itm1 8
...
140 1/1/03 G itm20 14
141 1/2/03 A itm1 7
...
160 1/2/03 A itm20 16
161 1/2/03 B itm1 9
...
281 1/3/03 A itm1 22
...

There are 7 categories A, B, C,... G. Each category
contains 20 Items per day, and a count of each item in
each category for each day. Someone at my place is telling
me that the correct way to create my table to to have 2
tables Master Table, Detail Table.

The Master table would contain the ID field, Date field,
and Cat field. The Detail table would contain the ID
field, Itm field and Count field. The argument is that
each category should be listed only one time per day, and
relate to the Detail table by ID. Data would now look
like this:

Master Table
ID Datefld Cat
1 1/1/03 A
2 1/1/03 B
..
7 1/1/03 G
8 1/2/03 A

Detail Table
ID Itm tCount
1 itm1 ...
1 itm2 ...
...
1 itm20 ...
2 itm1 ...
...

This seems a little redundant to me. You have less rows
in the Master table but the same number of rows in the
Detail table as with my original plan of using just one
table. The second design contains an extra column and an
extra table and joins I would now have to deal with.

So my question is - for my purposes - just to query count of items per
category per date range (real basic queries),
which of the 2 designs described here is more
correct/practical? Any suggestions appreciated.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2
A good example of our discussion is the Categories form in the Northwind
Sample Database that ships with your version of MS Access. This form has
Categories as the main form and Products in the subform.

Denny G.
"mm nn" <bb******@hotmail.com> wrote in message
news:3f***********************@news.frii.net...
Hi,

I want to create a table like this:

ID Autonum
Datefld Date
Cat Text
Itm Text
tCount Number

Data would look like this:

Data would look like this:

ID Datefld Cat Itm tCount
1 1/1/03 A itm1 3
2 1/1/03 A itm2 4
...
20 1/1/03 A itm20 2
21 1/1/03 B itm1 4
22 1/1/03 B itm2 5
...
40 1/1/03 B itm20 7
...
121 1/1/03 G itm1 8
...
140 1/1/03 G itm20 14
141 1/2/03 A itm1 7
...
160 1/2/03 A itm20 16
161 1/2/03 B itm1 9
...
281 1/3/03 A itm1 22
...

There are 7 categories A, B, C,... G. Each category
contains 20 Items per day, and a count of each item in
each category for each day. Someone at my place is telling
me that the correct way to create my table to to have 2
tables Master Table, Detail Table.

The Master table would contain the ID field, Date field,
and Cat field. The Detail table would contain the ID
field, Itm field and Count field. The argument is that
each category should be listed only one time per day, and
relate to the Detail table by ID. Data would now look
like this:

Master Table
ID Datefld Cat
1 1/1/03 A
2 1/1/03 B
..
7 1/1/03 G
8 1/2/03 A

Detail Table
ID Itm tCount
1 itm1 ...
1 itm2 ...
...
1 itm20 ...
2 itm1 ...
...

This seems a little redundant to me. You have less rows
in the Master table but the same number of rows in the
Detail table as with my original plan of using just one
table. The second design contains an extra column and an
extra table and joins I would now have to deal with.

So my question is - for my purposes - just to query count of items per
category per date range (real basic queries),
which of the 2 designs described here is more
correct/practical? Any suggestions appreciated.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #3
Thanks for your reply. I am just thinking that dealing with one table is
easier than dealing with two tables. I guess either way would be correct, but
I just don't see any benefit from having a master table and a detail table. One
table would seem like less work because I would not have to deal with
relationships, it would be one less column to deal with (link ID to ID). It
looks like it could be one or the other.
Nov 12 '05 #4
TC

"Rpng123" <rp*****@aol.com> wrote in message
news:20***************************@mb-m22.aol.com...
Thanks for your reply. I am just thinking that dealing with one table is
easier than dealing with two tables. I guess either way would be correct, but I just don't see any benefit from having a master table and a detail table. One table would seem like less work because I would not have to deal with
relationships, it would be one less column to deal with (link ID to ID). It looks like it could be one or the other.


You need to read
http://support.microsoft.com/support...es/Q100139.ASP

HTH,
TC

Nov 12 '05 #5

That was a very interesing article. So I am now convinced. My actual
question should have been - which is better? Less tables or less
repeating rows?

I was thinking less tables, but the literature appears to say that less
repeating rows is correct for rdbms. So I will go with that.

How about this? The place where I am at they have the master table and
detail table, but the data in the detail table is stored horizontally.
Like 20 int fields. These fields are what I was calling Itm fields.
Each category has 20 Items. Instead of storing data like this in the
detail table:

ID Itm1 Itm2 Itm3 ... Itm20
1 3 17 13 8
2 4 6 5 19
...

wouldn't it be more correct to store it this way in the detail table?

ID Itm tCount
1 itm1 3
1 itm2 4
...itm20 8
2 itm1 4
2 itm2 6
...
2 itm20 19
...

Then you pick the data you need and pivot it horizontally. Isn't that
the correct way to do it? Just asking.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Gleep | last post by:
sorry i didn't explain it correctly before my table is like this example fields: ID name username outcome date1 date2 date3 (etc..) - date15 price1 price2 price3 (etc..) I know that...
0
by: Philip Meyer | last post by:
1) setting image as Background with alignment in center not working..help Explanation : i need to set a image as background and also it should be dispalyed in the center.i am using apache fop...
6
by: BT | last post by:
I'm trying to format a three column table and I can't get things to line up the way I need to. The first column is text of variable length that might wrap onto multiple lines. It is within...
15
by: kimi | last post by:
I have just started working on a project that is partially complete. It is an application that is using access to store test results. The test results are being stored in two Access 2000 databases....
5
by: nishantxl | last post by:
Hi there, I am looking to design a project using C++ The main objective of the project is to display details of periodic table elements such as periodic element name, properties(such as atomic...
13
by: Giggle Girl | last post by:
Hi there, I am having a problem with the behavior of Firefox, where lefthand column content is not resized properly after it is "collapsed" and then "re-expanded". An online demo is available...
5
by: rAinDeEr | last post by:
Hi, I have a web application with a table to store terms and conditions of a Company. This may some times run into many pages and some times it may be just a few sentences. It is a character...
22
by: klenwell | last post by:
I'm in the process of refactoring the php code base I've amassed over the last few years into an object-oriented framework. I'm about to start in on the authentication/login extension and I've...
8
by: =?Utf-8?B?eWRibg==?= | last post by:
I need to write a program validate a text file in CSV format. So I will have a class DataType and a lot of of derived class for various type, e.g. IntType, StringType, FloatType, MoneyType,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.