Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some more doubts?

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a few doubts in mind
1. Is there any flaw if i have a table with no primary keys ? I mean, am i risking the quality of my design, doing so?
2. Suppose i have a table TableA with 3 fields, a, b, c. Suppose a and b are the combinational keys. Consider these rows of TableA
1,1, Gen
1,2, Mr
1,3, Mrs
1,4, Fr
......
Suppose i run a query to get me all c's where a = 1, then will i always get them in the order Gen, Mr, Mrs, Fr.?
What r the rules that govern the order in which i get the result rows.
Regards
Saj
 
Tomasz Piasecki
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Re: Q1.: It all depends on the DataBase type you are using if it is Oracle 8-up, then, as far as I know, you must declare PK and FK otherwise you will receive errors when creating tables.
If you use mySQL I read some toutorials that did not specify any keys whatsoever, and it was working fine. However I've been tought that a good database design always requires declaring PK and FK. If you do not specify them it is a performance issue of finding data in your database. If the database is fairly small there shouldn't be a problem, but if you have to manage huge database then... lots of trouble.
Q2. If you don't do "order by" in your SQL query then you will get the data as is. (SEE: O'Reilley SQL*Plus reference for use of: "group by" and "order by").
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic