jeudi 25 octobre 2007

Chapter 2. The Relational Model

  • to become an efective sql programmer,you will familiar whit the relation model.
  • the model describes how to perform a common algebric operations on database tables in much the some ways that they're performed on matimatical sets.
  • tables are collection of disting elements having common properties .
  • model=table=file.
  • attribute=column=field.
  • tuple=row =record.
  • a database is collection of one or more tables .
  • tables is a two dimensional grid caracterized by rows and columns.
  • table has a unique name within database
  • each column represent a specific attribute
  • each column has a domain that restricts the set of values allowed in that column.
  • a domain is a set of constraints that includes restriction on a values data type length ,format ,range ...
  • the order of columns is unimportant.
  • each column has a name that identifies it within table (you can reuse the same column in other tables.
  • no two rows in the table can be identical .
  • each row in a table is identified uniquely by its primary key.
  • a DBMS uses two type of tables :user tables and system tables
  • user tables store user definied data.
  • system tables contain metadata about the database such as structurel information ,physiqual details....
  • every table has exactly one primary key (remember that the relation model sees unorded set of rows there's no concept of a next or preveriuos row you can't identify the rows by position with out key primary some of data would be inaccessible).
  • a primary key is unique because it identify single row in a table.
  • primary key is simple or composite (one column key is called a simply key,and a multiple columns key is called a composite key).
  • names generally make poor keys because there are unstable.
  • database designer create unique identifier when natural or obvious ones (such as a names) won't work.
  • database designer forgo common unique identifier such as social securite numbers ,instead they use artificiel key that encode internal information that is meaningfull inside database user organization(for example employee ID might embed the years that the person was hired).
  • we need a way to navigate between tables =>the relational model provide a mechanisme called a foriegn key to associate tables .
  • the foriegn key has this caracteristics:
    • it's a column reference value in some other table.
    • it ensure that a row in one table have corresponding row in other table.
    • a foreign key establishes a direct relationship to the parrent table primary kay.
    • foreign key have the some domainas the parent key.
    • foreign key values are not unique in their own table.
    • allowing nullin a foreign key column complicates enforcement of referential integrity.
  • a relationship can be:
    • one-to-one
    • one-to-many
    • many-to many
  • one-to-one:each row in table A can have at most one matching row in table B.
  • one-to-many:each row in table A can have many matching rows in table B.
  • many-to-many:each row in table A can have many matching rows in table B and each row in table b can matching rows in table A.
  • redundancy is the enemy of databases user and administrators.
  • normalization is the process a serie of stepof modyying tables to reduce redandancy.
  • the relational model definies three normal forms.
  • frist normal form:
    • a table has columns that contain only atomic values(atomic value is a single value that can't ce subdevided).
    • has no repeating groups
    • to fix these problems store the data in two related tables.
  • second normal form:
    • it's primary key is a single column (the key isn't composite).
    • all the columns in the tableare part of the primary key.
    • has no partial function depending
  • the DMBS provide operators and function that let you extract and manipulate the compenents of atomic values if necessary such as substring() function to extract the telephone number area code
  • thrid normal form
    • has no transitive dependencies
    • a table contains a transitive dependency if a non key column value determines another non keycolumn values.
    • for each non key ask"can i determine a non key column if i know any other non key column values".
      • if no=>the column is no transitively dependent(good).
      • else =>the column is transitively dependent (bad).

chapiter 1 :DBMS Specifics(résume)


resume of chapiter 1 (VISUAL QUICKSTART GUIDE SQL Second Edition)
  1. you need a database management système to runs sql programs.
  2. microsoft access graphical interface let you run only one statement at a time.
  3. the other system (all DBMS server) let you run in interactive mode.
  4. file maker pro (www.filemaker.com) is a popular desktop data bases programs.
  5. sybase adaptative server (www.sybase.com) is a popular commercial DBMS.
  6. microsoft access is appropriate for managing small and meduim size databaeses.
  7. in access you must turn in ANSI -92 sql query mode to run sql statement.
  8. microsoft sql server is a commercial DBMS that support very large databases and transactionsto download click here .
  9. oracle is a leading DMBS.
  10. other DBMS (mysql,IBM DB 2 )if you don't like the command prompt of mysql ,you can try mysql control center (MYSQLCC).
  11. you can learn about open sources software at www.opensource.org.

blagues

firefox
A quoi peut bien servir Internet Explorer fourni avec windoze XP ?
Tout simplement à aller sur http://www.mozilla.org/products/firefox/ pour récupérer Firefox
microsoft
Bill Gates devient l'actionnaire principal du laboratoire qui fabrique la pilule Viagra. Comme quoi, s'il en agace certains, il en fait bander d'autres !!!
La question que l'on se pose :
- Bilou va-t-il commercialiser le Viagra de la même façon que Windows ?
Vous imaginez l'assistance téléphonique ?
- Bonjour, ici le support technique Microsoft Viagra98®.
- Bonjour, j'ai un problème, euh, ..., comment dire, de configuration.
- Je suis à votre écoute.
- Ben euh, voilà: c'est quand je fais la brouette bigoudaine juste après une turlute avec option émulation "Bois de Boulogne", j'ai la couille gauche qui gonfle comme une pastèque.
- Vous avez quoi comme matos ?
- Euh, ..., mon 21cm d'origine. Il date un peu mais jusqu'à maintenant, il marchait au poil ...
- Ouais, c'est un peu court. Vous devriez upgrader en 23cm. Quelle fréquence?
- 120 coups minutes. c'est pas assez?
- C'est vraiment pas terrible, mais ça devrait marcher quand même. Pensez à upgrader en 300 coups-minute. Et vous utilisez quoi comme préservatif ?
- Ben, Durex Vanille Fraise, comme toujours ...
- Ah ben voilà. C'est imcompatible. Vous devez absolument utiliser Microsoft Condom98®. C'est distribué gratuitement avec l'abonnement à MicrosoftPartouzeEntreHommes97®.
- Ah ..., Ca va pas être incompatible avec ma copine, ça ?
- Votre copine ? Je n'ai pas d'infos là dessus, c'est pas un produit Microsoft®.
- Bon, ..., merci quand même ....
- A vot'service.

Multidimensional Arrays

#include
using std::cout;
using std::cin;
using std::endl;

void affiche(int data[][3]);
int main()
{
int array1[2][3]={{1,2,3},{3,4}};
int array2[2][3]={{1},{2}};
int array3[2][3]={{1,2},{6,7}};

cout<<"la 1 ere matrix est"<<
affiche(array1);
cout<<"la 2 ere matrix est"<<
affiche(array2);
cout<<"la 3 ere matrix est"<<
affiche(array3);
system("pause");
return 0;
}
void affiche(int data[0][3])
{ for(int i=0;i<2;i++) j="0;j<3;j++)"><<" " ; cout<
}
}
the function must know exactly how many elements are in each row so it can skip the proper number of memory locations when accessing the array

Sorting Arrays with Insertion Sort

this program sort the values of 10 elements into ascending order
#include
using std::cout;
using std::cin;
using std::endl;
#include
using std::setw;


int main()
{
const int arraysize=10;
int array [arraysize];
int insert;
cout << "entre the array:\n"; // output original array for ( int i = 0; i <>> array[ i ];
cout << "Unsorted array:\n"; for ( int i = 0; i < next ="1;next0) && (array[move-1]>insert))
{
array [move]=array[move-1];
move--;
}
array[move]=insert;
}
cout << "\nSorted array:\n";

// output sorted array
for ( int i = 0; i < arraysize; i++ )
cout << setw( 4 ) << array[ i ];
system ("pause");
return 0;
}