Solved

Design Question!

Posted on 2011-09-12
4
220 Views
Last Modified: 2012-05-12

I have two tables:

LLocation (LenderId RegionId StateId CityTypeId)

LCity (LenderId CityId)

Each lender will be there in different regions,
inside region there will be state,
inside state there will be citytypes,
inside citytype there wil be cities
one lender will have only one city

RegionId,StateId,CityTypeId will be inserted the value null.
if all region or all state or all citytype selected

I need a sql query which to

insert and update into these two tables

and a query to

search based on LenderId RegionId StateId CityTypeId
where  Lenderid RegionId CityTypeId  are dropdown
and StateId  will have a text box value


Note: If the Null in a column , means all so just i need to show one
      row have null "all" not the sub values that comes under "all"
 
0
Comment
Question by:PeteEngineer
[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
4 Comments
 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
ID: 36523407
insert into LLocation (LenderId) values(@LenderID);

update LLocation set
  RegionId =@RegionId
  StateId =@StateId
  CityTypeId=@CityTypeId
where LenderId=@LenderID);
0
 
LVL 42

Expert Comment

by:dqmq
ID: 36523558
Wow..I don't know where to begin.  Please, please take a deep breath, slow down, and get some assistance with your table design, your understanding of nulls, and better express your requirements.  You are not ready to formulate queries.

Just to illustrate a couple "issues" that pop out:
1. Each lender can be in different regions, thus different states. thus different cities. But, one lender will have only one city??????

2. "Inside state there will be city types".  Are you sure?  I can only guess what a city type is, but NONE of my guesses would have city type within state.  Are you saying two states cannot have the same city type?  Or or you just describing one way of drilling down to a city of interest?  

3.  You do not have data that shows which state a city is in or which city-type describes a city.



 
   
0
 
LVL 8

Author Comment

by:PeteEngineer
ID: 36523618
one lender will have only one city?????? yes
 "Inside state there will be city types".  Are you sure? no
Are you saying two states cannot have the same city type? Yes



0
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 36523964
If a lender can only have one city.  And that city belongs to a city type which in turn belongs to a state which in turn belongs to a region, then the lender can have at most one region.  Do you see my confusion?

Also, you then have one table that shows city for a lendor and another that shows location for a lendor.  But city IS a location, so that's very confusing, too.  There is no relationship that shows a city's type, except the one that is implied by the lendor assignments.

Let me ask this.  If you assign a lendor to a city, does not the city determine the city type and the state and the region?    
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

691 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