Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-15-2012, 07:33 PM   PM User | #1
rawkas
New to the CF scene

 
Join Date: Oct 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
rawkas is an unknown quantity at this point
help please!

hi guys!

Last edited by rawkas; 11-15-2012 at 07:37 PM..
rawkas is offline   Reply With Quote
Old 11-15-2012, 07:37 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by rawkas View Post
hi guys, any chance with help on the following question? would be much appreciated!

MySQL is a relational database management system. The data is structured as a set of tables linked by relations. Assume the following database has been setup for you.


Properties
propId

postCode
1

CB1 4PY
2

CB2 9GH
3

CB23 4DG

Persons
perId

propId

firstName

lastName
1

1

Fred

Bloggs
2

2

Arthur

Brown
3

1

Mary

Bloggs
4

4

Nigel

Wilson

3.3.1 Write the SQL to list postcodes and names of people who live there.
3.3.2 Write the SQL to list postcodes and people who live there (where applicable) for all properties regardless of whether the property is inhabited.
3.3.3 Write the SQL to list people and postcodes (where applicable) for all people regardless of whether they live in a property that exists.
3.3.4 Given values for postCode, firstName, lastName write the SQL statements to create suitable entries for each table. HINT you may need to use Last_INSERT_ID() - assume propId and perId columns have been defined as AUTO_INCREMENT.





thanks alot!

This hasn't a thing to do with PHP. Moving to MySQL forum. In the future please choose a better title for your threads.

This is clearly homework. Please post your current SQL attempts and the problem you are currently seeing with it.

Last edited by Fou-Lu; 11-15-2012 at 07:39 PM..
Fou-Lu is offline   Reply With Quote
Old 11-15-2012, 07:49 PM   PM User | #3
beaverking1989
New to the CF scene

 
Join Date: Nov 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
beaverking1989 is an unknown quantity at this point
Okay, I feel the need to chip in and help my associate present this question more clearly.

This is how the question is supposed to look.


We really do appreciate any help you can provide as we're both stumped. Thanks for your time.
beaverking1989 is offline   Reply With Quote
Old 11-15-2012, 08:24 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
And that's fine, but where is the current SQL in use and the problem you are having with it?
You can't just present us with a homework assignment and expect that we should do it for you. That would be called cheating; however we can help you fix existing code (or in this case queries) by walking through the problem and guiding you to the proper solution.
Fou-Lu is offline   Reply With Quote
Old 11-15-2012, 09:31 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
And on top of that, if the database is PROPERLY DESIGNED and uses correct RELATIONAL INTEGRITY, then task 3.3.4 is impossible. For that matter, the data as presented there is impossible. So somebody is teaching you bad database design.

Specifically, propid in the PERSONS table should be a foreign key to propid in the PROPERTIES table. And so the propid of 4 in the PERSONS table would be impossible in a correctly designed and implemented database.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:39 AM.


Advertisement
Log in to turn off these ads.