1

I have that database diagram (MySQL). Each Book has assigned a BookLanguage. Each BookLanguage has two different LanguageNames (the globalization purpose). And also, each Book can have an additional BookLanguage (but it's not required).

And here's the problem - I'm stuck here while building a SQL query for searching for that Books, whose have some string in the BookLanguageNames. It's simple to build the query with joining the BookLanguage and BookLanguageNames but how to cope with the AdditionalBookLanguages ?

enter image description here

7
  • What data do you want returned? We can't help if we don't know what you're looking for. Commented Nov 7, 2012 at 13:21
  • I want to get these Books, whose have some string in the Name column in the BookLanguageNames and also (if exist) in the AdditionalBookLanguages Commented Nov 7, 2012 at 13:23
  • 1
    What is the Code column in the BookLanguage table? Is it necessary? Why is not in the BookLanguageNames or AdditionalBookLanguages? Commented Nov 7, 2012 at 13:30
  • the Code column is not important in that case Commented Nov 7, 2012 at 13:32
  • it's not normalize, additionalbook,book and booklanguage you have a loop, you should create only one relationship between them Commented Nov 7, 2012 at 13:50

1 Answer 1

1

How about simplifying the database design? Have three tables Book, BookLanguageName (both of them similar structure to yours) and, instead of AdditionalBookLanguage and BookLanguage have a "lookup table" - BookLanguage:

  1. Book - here you keep all the information about the books.
  2. BookLanguage - only three columns: BookID, BookLanguageID (or Code) and a boolean is_additional. BookID and BookLanguageID would be a composite primary key.
  3. Language - here you keep all information related to a particular language.

In such case, writing query would be easier.

Sign up to request clarification or add additional context in comments.

2 Comments

sound very interesting, I'll consider that option. Thanks for the idea !
You're welcome, Tony! Please let us know later what was your final solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.