dimanche 16 mars 2008

samedi 27 octobre 2007

Chapter 3. SQL Basics

  • SQL is based on the relational model but doesn't implement it faithfully
  • SQL is a free form language whose statement can :
    • be in uppercase or lowercase.
    • start in any column.
    • an intrenative sql statement ends with a semicolon.
  • an identifier is a name that lets you refer to an object(schema,database ,column,key).
    • database name must be unique.
    • table and view names must be unique.
    • column ,key,index and constraint names must be unique .
  • you can give the same name of column in diferent tables.
  • here's some more advice for choosing your identifier names :
    • use a lowercase letters.
    • names_with_underscore are easier to read than namewithunderscore.
    • if you are worried that your identifier might be a reserved word in some other SQL dialect just add an underscore (for example element_).
  • use the statement create table and alter table to defineor change a column data type.
  • database designers choose data type carefully.
  • use charactere string data types to represent text ,a character string or just string
    • its lenght can be fixed or varying.
    • it's a case sensitive('A' come before 'a').
    • in sql statement ,a string is surrouded by a single quotes.
  • charactere string types :
    • CHARACTERE(lenght) represent a fixed numbers of characteres(CHARACTERE and CHAR are synonyms) .
    • CHARACTERE VARYING (lenght) the DMBS store the string as is and doesn't pad itwith spaces.
    • NATINAL CHARACTERE:this data type is the some as charactere except that is hold unicode charactere (NCHAR).
    • CLOB:the caractere large object type is intended for use in library databases that holds vast among of text.
    • NATIONAL CLOB:is like CLOB execpt that is hold unicode characteres.
  • BINARY LARGE OBJECT TYPE: BLOB are used to store large amounts of multimedia data(graphic,audio,video,photo...),scientific data.
    • BLOB can't be used as keys or indexes
    • BLOB can be compared for only equality (=)or inequality(<>).
    • you can't used BLOB with DISTINCT or GROUP BY or ORDER BY clauses.
    • DMBS BLOB types :sql server binary,varbinary,image.
  • EXACT NUMERIC TYPE :to represent exact numerical value
    • it can be negative or positive number.
    • it's an integer or a decimal number.
    • it has a fixed precision and scale.
    • exact numeric type:
      • NUMERIC :represent a decimal number ,storedin a column defined as NUMERIC(precision,scale).
      • DECIMAL is similaire to numeric ,the diference is that decimal has a precision greater that numeric.
      • integer
      • smallint: is similaire to integer but it might hold a smaller range of values.
      • bigint
      • sql server exact numeric type :bigint,iny ,smallint,tinyint,decimal,numeric.
  • APPROXIMATE NUMERIC TYPES:an approximate numeric type has thesecharactéristics:
    • it can a negative or positive number
    • it typically is used to represent the very small or very large quantities common intechnical ,scientific calculations.
    • approximate numeric type:
      • FLOAT:represent a floating point number,stored in a column defined as FLOAT(precision).
      • REAL:is similaire to float exceptthat the DMBS defines the precision(real takes no argument).
      • DOUBLE PRECISION
    • sql server :float,real.
  • BOOLEAN TYPE:have three values :true ,false,unknown.
    • sql server :bit,
  • DATA TIME TYPE:use the data time type to represent data and time.
    • you can compare two datatimevalues.
    • sql server:datetime,smalldatetime,rowversion.
  • OTHER DATA TYPE:the sql standard define other data type than the one covered in the preceding section.
    • you can find data type for:network and internet @,links to files stored outside the databases.
    • sql server:uniqueidentifier,identity.
  • NULLS :when your data is imcomplete you can use a null to represent a missing or unknown values.
    • NULLs are eliminated by splitting the original tableinto one-to-one relationship.

vendredi 26 octobre 2007

Chapter 8. Pointers and Pointer-Based Strings

  • pointer variables contain memory addresses as thier values.
  • pointer must be declared before they can be used( for example int *ptr =>ptr is a pointer to int ).

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;
}