Mysql Linking help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bdeonline
Forum Commoner
Posts: 42
Joined: Sun Jul 18, 2004 10:45 am

Mysql Linking help

Post by bdeonline »

Here is what I have:
Tables:
color
design
font
font_color
items

I need to link color, design, font, and font_color to items but each item will have a different colors, designs, fonts, and font_colors and different amouts of each. I know how to use Mysql joins.

Anyone have a idea on how I would go about making a db for this?
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

What are the columns for these tables and how do they relate to each other? What are you trying to do in this application? Once we know that, am sure the answer will be easy enough...

fv
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Search for [google]normalization[/google]. There have also been many post in this forum regarding it.
bdeonline
Forum Commoner
Posts: 42
Joined: Sun Jul 18, 2004 10:45 am

Post by bdeonline »

fractalvibes wrote:What are the columns for these tables and how do they relate to each other? What are you trying to do in this application? Once we know that, am sure the answer will be easy enough...

fv
Ok I will try to explain it better:
I have Items in a Items table each item will have mulitple and different colors, designs, fonts, and font_colors. I need to find a way to put them together.

The only way I have thought of is to add a field for each one:
example:
id / red / blue / green
1 / 1 / 0 / 1
2 / 0 / 0 / 1

And doing that on ward with desings fonts ect. But that would add up to 70 or more fields and add alot of unwanted bloat.
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

Ok so basically you need to represent entities known as Items, which can have multiple attributes.


color
design
font
font_color

These above can become Domain tables:
Color_table
ID
ColorName

Font_Table
ID
FontName

etc.

Then your Item table can have:
Item_Table
ID
ItemName
ItemDescription
ColorID
FontId
DesignID
FontColorID

etc.

Populate your domain tables with the range appropriate to each.

fv



items
Post Reply