|
-
Reef Shark
Access question related to tables.
I have a pretty advanced structure of tables (AKA entities) that have relationships for my current database project. I am having some difficulty determining the correct setup for this database. Any suggestions and feedback would be wonderful, in order to direct me in a more logical direction. Here is the problem.
The database is for a horse breeding ranch and there are two kinds of horses: horses that are owned by the farm and customer horses. For the most part they have the same characterists (and are currently as one "Horse" table). There are, however, several entities(tables; such as Show Results, Pedigree) that are associated with only farm horses and an entity that is only associated with customer horses(Imports). Should I somehow split the Horse entity? Am so confused about this part of database! I'm only posting this particularly odd question because I have no other place to go!!!
------------------
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Me
"Tink"
1 GHz Tbird on A7V, 384MB PC133 RAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM nic, Intellimouse Explorer
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Ursus Arctos Moderatis
Here's what I would do.
And here's the method to my madness 
Make a "Horse Types" table so you can relate horses to a given Horse Type (Owned, Customer, etc).
Make a Shows and Show_Results Table, so you can keep track of Shows, and then relate horses to the Shows Table, and store their results.
The "Pedigree" and "Import" attributes sound like "yes or no" type sitautions to me, so I would set them as bit flags (true/false,yes/no,1/0) in the Horses Table.
Make sense? From the limited information you gave us, that's how I would attack it. Others might take a different approach. There's no one right way, but some methods are better than others.
-
Reef Shark
Originally posted by Grizzly:
And here's the method to my madness 
Make a "Horse Types" table so you can relate horses to a given Horse Type (Owned, Customer, etc).
Make a Shows and Show_Results Table, so you can keep track of Shows, and then relate horses to the Shows Table, and store their results.
The "Pedigree" and "Import" attributes sound like "yes or no" type sitautions to me, so I would set them as bit flags (true/false,yes/no,1/0) in the Horses Table.
Make sense? From the limited information you gave us, that's how I would attack it. Others might take a different approach. There's no one right way, but some methods are better than others.
First I would like to congratulate and thank you for the best reply i have ever received in SharkyForums history. Thank you so much... unfortunately, I am admitedly not familiar with these methods.
I like the bit flag idea and tried to impliment it for a different aspect of the same database, but I was unsure of the correct way to use it as far as entity relationships go? In other words, how do I connect the bit flag from the parent entity to the corresponding child entity? Just connect relationship line?
Second, I am not understanding how creating the Horse_Type entity seperates my horses into two subgroups if (as drawn in your great diagram), the Horse_Type entity is not related to Show_Results... I had a piss-poor professor in database design class... kept talking about normalization... something my logic is trained beyond.
If you could explain these two techniques a little more for me, not only would I be even more grateful for your help, I'd feel comfortable in moving forward. Thx.
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Ursus Arctos Moderatis
-
Reef Shark
I think you misunderstood me a little bit, which is okay because it is always better to undershoot when teaching someone, rather than overshoot. 
I fully understand how relationships and normalization work. In fact, my head is so ingrained with normalization that I have trouble viewing the different normal forms because I initially see the data already in 3rd Normal Form. Don't get me wrong, your further explanations HAVE helped.
What it is that I am having trouble with the bit flags is why do I need them? For querying purposes? I can store the data in the subordinate entities even if I don't have a horse_type entity, correct? I mostly want to eliminate data redundancy and make sure that I'm not going to run into problems on down the road due to the fact that all the horses are stored in the same entity, even though many of the subordinate entities only apply to one or the other of the "types" of horses. So, if adding this Horse_Types entity eliminates some sort of problematic thing, what might it be? I will certainly impliment it if something exists.
Furthermore, I just want to clarify my understanding of the bit flag operation. By placing a bit flag in a parent entity, what must be included in the child entity? This field is associated with what field in the child entity, and how? Does it determine "Only" that the parent entity does indeed contain a record in the child entity for purposes of acknowledging this from a user perspective, or does it serve some database relationship role that i'm not seeing?
I'm sorry if I seem to be asking redundant questions, I just REALLY want to rule out any possible problems and understand what it that I'm doing here since my professor failed to teach me anything new. I so very much appreciate your willingness to help.
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Ursus Arctos Moderatis
I really don't think I follow your questions here...but I'll try and respond the best way I can.
Breaking out Horses into seperate tables, depending on if they're "Pedigree" Horses, or "Import" Horses is simply bad design. You pretty much need to think of this in an Object Oriented way. A "Horse" is an object, and as an object...Horses have certain attributes. So we create a table for all "Horses," and define attributes for our Horses in the Horse Table, or potentially in related attributes tables.
By having a "Horse_Type" lookup table, we can define "n" number of horse types, relating to the Horse Table.
The real key to this method is extensibility. By having a Horse_Type lookup table, we can very easily add new Horses with new Horse Types to our database.
For example:
Say 1 year from now there's a new "Horse Type," for our puporses we'll call them "Yellow Horses." Ideally, we could make a single entry in the Horse_Type table, and then be able to add as many "Yellow Horses" to our "Horse Table" as we need. Very little query or code modication will be necessary.
But if you decided to take the route of making different tables for each Horse, than you'd be forced to create a *new* table for Yellow Horses...which would more or less have the same fields as other Horse tables, but with a few minor differences. This would then require you write some new queries to pull data from the new horse table, and write new code accordinfly to display Yellow Horse data. It becomes increasingly more difficult, and messy, as each new Horse Type comes into the picture.
So the real key with keeping all Horses in the same table, is extensibility. The ability to have your database / application grow as needed, quickly...and easily. That's what good design is all about. Now understand that I put no more than 5 minutes of thought into my above diagram...and had I known more about the subject or the application I'm sure I would've done some things differently. But take this concept and apply the best way you can and apply it accodingly...sound design saves everyone from headaches in the long run 
-
Reef Shark
AWESOME! You elimintated any doubts I had about creating my database in this way. I like it. I am already hard at work putting this method of design to work for me.
If you're interested in more information, here is the farm's website .
[This message has been edited by Nephalim (edited December 18, 2001).]
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Reef Shark
Would it cause a problem to have two associative entities based on the same three parent entities? I would combine the two, but they are independent of each other. For each of one of the two associative entities, one record may exist in the same circumstance that many exist in the other, and vice versa. To elaborate, the three parent entities are Show, Horse and Rider, and the two associative entities are Show Results and Awards. I don't see any problem with this, but again I'd like to clarify.
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Ursus Arctos Moderatis
-
Reef Shark
Oh, I apologize Grizzly. I thought you were familiar with these ghastly terms that I've been wading through... I can now safely switch back to normalcy. So to get back to my question, what I mean by associative entity is that they tie in other entities because they "associate" with them. For example, Awards "associates" a show, a horse and a rider together to form an Award where the rider and the horse both receive the same award, which happens to be a result of the show. To further explain, here is my entire(geez, the whole project is going public ) table relationship diagram: Tables. Skip the crap and type "tables.jpg" in the address line... angelfire is on crack!
[This message has been edited by Nephalim (edited December 19, 2001).]
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Ursus Arctos Moderatis
Ah, well I can't see that image because of Angelfire image security. But I follow what you mean.
Now...my first inclination is that an "Awards" table would be 100% redundant to the Show_Results table? Or are you replacing "Show_Results" with Awards?
-
Reef Shark
I edited my other post with directions on how to get around the image security...
As I said before, Awards and ShowResults must be separate tables. However, Rider, Horse and Show will all be connected to both tables... see the diagram for more information.
------------------
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Me
"Tink"
1 GHz Tbird on A7V, 384MB PC133 RAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM nic, Intellimouse Explorer
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Reef Shark
Also, I'd like to run an AppendQuery the first of every month. How do I do this? Especially if Access probably won't be running 24/7???
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Originally posted by Grizzly:
- Horses => Horse_Types -- 1 to 1
- Horses => Awards -- 1 to MANY
- Horses => Riders -- 1 to 1
- Horses => Show_Results -- 1 to MANY
- Shows => Show_Results -- 1 to MANY
Actually, I think it would be something like this:
- Horses => Horse_Types -- MANY to 1 <-
- Horses => Awards -- 1 to MANY
- Horses => Riders -- MANY to MANY <-
- Horses => Show_Results -- 1 to MANY
- Shows => Show_Results -- 1 to MANY
A definition-list table always has one-to-many relationship, as in Horse_Types. One type has many horses, otherwise it wouldn't be any point in having it.
Horses-Riders, I guess a rider could ride many horses, and a horse could be ridden by many riders. Therefore you would need, as you said Grizzly, a new relation with two foreign keys, the primary key from horses and the primary key from riders. A sort of who's using what list.
About the awards, there could be a many-to-many relationship there, with a year as an identifyer (Nicest-horse-99, Nicest-horse-00 and so on), but I dont't know about those business rules.
Always make a good data model first, you will get in trouble later if you don't. Ahh, the pleasure, the pleasure of database modelling.
-
Hammerhead Shark
Don't over-normalize... I knew some DBAs that loved to do that, and it became a nightmare...
Basically, if you have a choice of values for any particular field, break it out into a seperate table, then link it by an ID. If the field is totally free-form, it is harder to decide if you should seperate it or keep it in the main table.
For instance, lets say we have a category structure...
category
-----------------
cat_id integer
cat_name varchar(255)
catrel
-----------------
cr_id integer
cr_cat_id integer
cr_parent_id integer
This system makes the data very clean and easy to work with, given sub-selects, or you could loop. cr_parent_id is a cat_id or null if top-level, the rest are fairly obvious.
Another system that works well is putting everything in one table... But, it often causes speed problems due to the fact that the entire record is longer!
category
--------------
cat_id integer
cat_parent_id integer
cat_name varchar(255)
So, due to this example, it is obvious that the less you have directly in a record, the better... Therefore, you need to find a balance, but here is an idea...
horses
-----------------
hrs_id integer
hrs_name varchar(255)
hrs_own_id integer
hrs_type_id integer
hrs_stall char(10)
horse_award
-----------------
awd_id integer
awd_hrs_id integer
awd_type_id integer
awd_level integer
awd_date timestamp
awd_text text
horse_owner
-----------------
own_id integer
own_name varchar(255)
own_address varchar(255)
own_phone varchar(255)
(... etc)
horse_type
-----------------
type_id integer
type_name varchar(255)
type_tpgrp_id integer
tpgrp
-----------------
tpgrp_id integer
tpgrp_name varchar(255)
.
.
.
etc
This is a fairly heavily normalized idea, and is likely not even what you need, but, this is my system for designing databases... My naming convention is a bit odd, but it comes from my years working with high-end IBM products that use IBM schemas. The field naming is my variation on the IBM style, but slightly looser. They often use 2 or 3 character table identifiers, then a field name. The downside is that there is no right-side convention, so you are not always sure if it is an id (relating to another table), or if it is a field with data in it... With my system, I just look for one or two underscores '_', and if I see two, I know I need to get the data from another table. And I use the same field name to make it easier -- hrs_own_id is a value from own_id... very easy. But, use your own convention/style.
Just my $0.02...
------------------
Founder of the Sharky (Ultra) High-Resolution Club[SHRC] [SHRC:ETCH]
[SGC Ultimate pass... Don't read anything I post unless you want a headache]
SF Linux Hippie Club Vice-Vice President [Card]
America Online Doit Mourir
Everything you ever wanted to know and see about e-dawg...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|