 




<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IT Answers &#187; primary key</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/tag/primary-key/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers</link>
	<description></description>
	<lastBuildDate>Sat, 25 May 2013 23:18:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Constraints (MySql,tables,null,PK,FK etc)</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/constraints-mysqltablesnullpkfk-etc/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/constraints-mysqltablesnullpkfk-etc/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 19:52:39 +0000</pubDate>
		<dc:creator>Ak1bo78</dc:creator>
				<category><![CDATA[constraints]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[NOT NULL]]></category>
		<category><![CDATA[NULL]]></category>
		<category><![CDATA[primary key]]></category>
		<category><![CDATA[tables]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hi all(waves) noob here ( ) ( yes you might look down upon me) ( ) never the less&#8230;.:)  Quick question: Tables made so far: department values (depno,dname) course values values (courseno) How would I create a table eg &#8220;Table budgets&#8221;&#8230;with values of two budgets (£100 and £200) for courses. 1.Courses are managed by departments. [...]]]></description>
				<content:encoded><![CDATA[<p><b>Hi all(waves) noob here ( <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) ( yes you might look down upon me) ( <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  ) never the less&#8230;.:)<br />
 Quick question:</p>
<p>Tables made so far:<br />
department values (depno,dname)<br />
course values values (courseno)</p>
<p>How would I create a table eg &#8220;Table budgets&#8221;&#8230;with values of two budgets (£100 and £200) for courses. </p>
<p>1.Courses are managed by departments.<br />
2.Department A manages course 1 and 2<br />
3.Department B manages course 3 and 4<br />
4.Department C manages course 5,6,7,8<br />
5.Department D manages course 9 and 10<br />
6.Department E manages no course<br />
7.Courses 1-5 each have a budget of £200<br />
8.Courses 6-10 each have a budget of £300 </p>
<p>I know the table needs primary key and foreign keys referencing two tables:department and course.</p>
<p>I have tried the following so far:</p>
<p>CREATE TABLE budgets (depno INTEGER NOT NULL,courseno INTEGER NOT NULL,dname (char)NOT NULL,budgetA INTEGER(200),budgetB INTEGER (300),PRIMARY KEY (depno) REFERENCES department (depno),FOREIGN KEY (courseno) REFERENCES course (courseno));</p>
<p>I have also tried:<br />
CREATE TABLE budgets (depno INTEGER NOT NULL,courseno INTEGER NOT NULL,dname (char)NOT NULL,budgetID INTEGER(1,2,3,4,5,6,7,8,9,10),PRIMARY KEY (budgetID) REFERENCES department (depno),FOREIGN KEY (courseno) REFERENCES course (courseno));</p>
<p>When mysl&#8217;d:<br />
Select budgetA from budgets where dname=&#8221;Department A&#8221;;</p>
<p>Answer should be:budgetA £200 </p>
<p>When mysl&#8217;d:<br />
Select budgetID(1),courseno(5) from budgets,course where dname=&#8221;Department C&#8221;;</p>
<p>Answer should be:budgetA £200 or £300<br />
depending if its courseno 5 or higher.</p>
<p>All help MUCH appreciated. Yes I know its a short question.Not!! lol well it might be simple for all you SQL pros out there.Ive only used 4months now&#8230;:)</p>
<p>Thanks,<br />
Akibo<br />
</b></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/constraints-mysqltablesnullpkfk-etc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Pros and cons of composite key as primary key</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/pros-and-cons-of-composite-key-as-primary-key/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/pros-and-cons-of-composite-key-as-primary-key/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 16:15:23 +0000</pubDate>
		<dc:creator>Bdpowell</dc:creator>
				<category><![CDATA[composite key]]></category>
		<category><![CDATA[primary key]]></category>
		<category><![CDATA[surrogate key]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I guess the title is pretty much the question. Just wondering what the pros and cons might be for using a composite key for a PK rather than a surrogate key. Thanks!]]></description>
				<content:encoded><![CDATA[<p>I guess the title is pretty much the question.  Just wondering what the pros and cons might be for using a composite key for a PK rather than a surrogate key.</p>
<p>Thanks!</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/pros-and-cons-of-composite-key-as-primary-key/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/14 queries in 0.018 seconds using memcached
Object Caching 404/421 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-26 00:28:45 -->