Solved

Database, simple question

Posted on 2011-09-24
2
367 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
2 Comments
 
LVL 16

Assisted Solution

by:Peter Kwan
Peter Kwan earned 50 total points
Comment Utility
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 450 total points
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now