?
Solved

Database, simple question

Posted on 2011-09-24
2
Medium Priority
?
395 Views
Last Modified: 2012-05-12
Hello experts!

Question about relations in database.

I have two tables:

1. Person
Name
Surname
Age

2.Features
Nice
Aggressive
Polite
Pretty
Ugly

Now I want to save "Features" data against "Person" data.
One person can have none, all or selected features.

1. What is the best way to save such data?
2. What is the best way to make two or more features mutually exclusive- for example someone
cannot be ugly and pretty at the same time.

Thank you

panJames


0
Comment
Question by:panJames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Assisted Solution

by:Peter Kwan
Peter Kwan earned 200 total points
ID: 36592227
I don't know if your Feature table have columns "Nice", "Agressive" etc; or the listed are the values. However, you may do like this:

1. You may combine both tables into one like this:

Person_Feature
(Name, Surname, Age, Nice, Agressive, Polite, Pretty, Ugly)

2. The best way is to implement the logic in your application code, rather than using database operations.
0
 
LVL 24

Accepted Solution

by:
johanntagle earned 1800 total points
ID: 36592230
1. I would assign a numeric personid and featureid for the Persons and Features table, respectively.  Then you store the relationship on a third table, storing the personid and featureid pair.

2.  Unfortunately MySQL doesnt support function based constaints, so I think you need to enforce this exclusivity in the application level.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question