Reputation: 1310
AspNetUser
-> child table Ad
Ad
-> child table Mobile Ad
Ad
-> child table AdsLocation
(multiple locations against one ad)City
-> child table PopularPlace
Questions:
Should I have to add relation between Mobile Ad
and Mobile
? (Mobile
entity should not be deleted on deletion of MobileAd
and there should not be repeated rows in Mobile
table )
Should I have to add relation of AdsLocation
with City
and PopularPlace
?
Write a query to get ads on the basis of companyName
(Mobile table) and should retrieve userName, title, price, companyName, modelName and multiple locations with cityName and popularPlaceName (in short retrieve a column from each table :) Method syntax should be preferred.
Upvotes: 0
Views: 64
Reputation: 2140
1) Yes you should create a relation between mobile and mobile ad because mobile ad is referencing mobile id.
2) Yes you should create a relation between AdsLocation and City because AdsLocation is referencing city id.
3) Until the relation in part 1 is not formed, this query will not be possible. However, while trying to write the LINQ Query for this question, I realized there are some design issues with your database. For example, can the same Ad be posted by different companies? At the moment your design allows it. Your design also allows any user to post the ad for any company. In real world, only marketing team of company X should be able to create ads for company X. I think you should spend some more time reviewing this design!
Upvotes: 3