- Prepare
- Databases
- Set and Algebra
- Databases - Keys
- Discussions
Databases - Keys
Databases - Keys
+ 0 comments bookname
+ 0 comments The question is a bit confusing, there are two case scenarios.
Case 1 - If we just look at the data, Booknames are not repeated anywhere. And we don't have to think about the test case since we just have to consider this particular data, also in test case it is written that no test cases are there in this question.
Case 2 - If we start considering the test cases, bookname and author will be composite key and can we consider them as primary key. But the people who are not from the book publishing industry might not know that, two books can't have the same name since there is a copyright issue. So, the bookname is the primary key.
+ 0 comments How's this problem medium?
+ 0 comments can anyone tell me how to write ans of this .. like ans is bookname soo i simply type --> bookname
+ 0 comments Different authors can write a book with the same title. A book can be published in multiple languages. So, "bookname" shouldn't be unique, and also "bookname" and "author" should also not be unique.
For this type of table, we should use semantically unique identifier as a primary key like ISBN, or any surrogate key should be used.
Anyway, it doesn't only a wrong question, but also spreading a wrong idea about database design for junior engineers who are learning SQL in HackerRank. Therefore, it is more like "harmful" question I feel, then it should be removed.
Sort 25 Discussions, By:
Please Login in order to post a comment