Journal
Dr. Alireza
Ebrahimi
Journal
Dr. Alireza
Ebrahimi
Journal Wednesday April 21st, 2008
1) How does the Google database
or Yahoo database work?
Both are search engines
but they have to have a database. They have to add, remove, and
update their information.
The captain cannot be late.
----------------------------------------------------------------------------------------------------------------------------
Conclusions
Google is designed to
be a scalable search engine. The primary goal is to provide high quality
search results over a rapidly growing World Wide Web.
Google employs a
number of techniques to improve search quality including page rank, anchor
text, and proximity information. Furthermore,
Google is a complete
architecture for gathering web pages, indexing them, and performing search
queries over them.
---------------------------------------------------------------------------------------------------
A large-scale web search engine is a complex system and much
remains to be done. Our immediate goals are to improve search efficiency and to
scale to approximately 100 million web pages. Some simple improvements to
efficiency include query caching, smart disk allocation, and subindices. Another
area which requires much research is updates. We must have smart algorithms to
decide what old web pages should be recrawled and what new ones should be
crawled. Work toward this
goal has been done in [Cho 98]. One promising area of
research is using proxy caches to build search databases, since they are demand
driven. We are planning to add simple features supported by commercial search
engines like boolean operators, negation, and stemming. However, other features
are just starting to be explored such as relevance feedback and clustering (Google
currently supports a simple hostname based clustering). We also plan to support
user context (like the user's location), and result summarization. We are also
working to extend the use of link structure and link text. Simple experiments
indicate PageRank can be personalized by increasing the weight of a user's home
page or bookmarks. As for link text, we are experimenting with using text
surrounding links in addition to the link text itself. A Web search engine is a
very rich environment for research ideas. We have far too many to list here so
we do not expect this Future
Work section to become much shorter in the near future.
---------------------------------------------------------------------------------------------------
Farzad
contributed this information from : http://www.readwriteweb.com/archives/yahoo_pipes_web_database.php
The Web is just a vast database of information.
Everyday, we interact with it without thinking about
that too much. We simply take our best query tool,
usually called Google, and fire away. Yet decades
before the web made its way into our lives, a
different kind of database revolutionized our lives.
The
Relational Database qualifies as one of our best
computer science inventions. Lesser known to the
non-techie crowd, it nowadays quietly stores
terabytes of information behind most familiar
ecommerce and corporate sites.

---------------------------------------------------------------------------------------------
Christian contributed
this from : From Wikipedia, the free encyclopedia
Googlebot
A Googlebot is a
search bot used by
Google. It collects
documents from the
web to build a searchable index for the
Google search engine.
If a
webmaster wishes to restrict the information on their site
available to a Googlebot, or another well-behaved
spider, they can do so with the appropriate directives in a
robots.txt file,[1]
or by adding the meta tag <meta name="Googlebot" content="noindex">
to the webpage.
[2] Googlebot requests to
Web servers are discernible from their
user-agent string 'Googlebot'.
Googlebot has two versions, deepbot and freshbot. Deepbot,
the deep crawler, tries to follow every link on the web and
download as many pages as it can to the Google indexers. It
completes this process about once a month. Freshbot crawls the
web looking for fresh content. It visits
websites that change frequently, according to how frequently
they change. Currently Googlebot only follows
HREF links and SRC links.
[3]
Googlebot discovers pages by harvesting all of the links on
every page it finds. It then follows these links to other web
pages. New web pages must be linked to from another known page
on the web in order to be crawled and indexed.
A problem which webmasters have often noted with the
Googlebot is that it takes up an enormous amount of bandwidth.
This can cause websites to exceed their bandwidth limit and be
taken down temporarily. This is especially troublesome for
mirror sites which host many gigabytes of data. Google
provides "Webmaster Tools" that allow website owners to throttle
the crawl rate.
[1]
-----------------------------------------------------------------------------------------------
When you search the keywords "dr ebrahimi" on different
engines, why is
www.drebrahimi.com on top?
is it the number of hits?

----------------------------------------------------------------------------------------------------
contribution by Steve
http://nsgd.gso.uri.edu/searchguide.html#Truncation
Advanced Searching
For those desiring more flexibility or additional search terms,
you may
now string 2 or more words in each term box and link them with
the search
operator of your choice in the pull-down menu to the right of
each term
box. The default (word or phrase) indicates ADJ (adjacent) so no
change is necessary during simpler searches. Search terms must
be
separated by a space or a comma. The search operators allowed
are:
AND (two or more terms)
OR (two or more terms)
AND NOT (two terms only)
NEAR (two terms only)
-------------------------------------------------------------------------------------------
JAVA
DATABASE EQUIVALENT TO THE C++ DATABASE
The following Java database program
demonstrates how your knowledge of C++ will help you to write Java
applications. You will realize that the control structures are the same
(while, if/else, for); however, there are differences in java file handling
and user input. File handling in java is a little more complicated due to
the class nature of the file. Input from the keyboard has to be parsed into
the desired format. There are two stages of compiling Java programs:
compilation and interpretation. The compilation of the .java file
creates a .class bytecode file that can be interpreted in virtually
any platform (Virtual Machine). One of the benefits of Java is its
portability and its ability to create applets that can be run on browsers.
Java does not have pointers and applets cannot directly access files due to
security restrictions. To read input or values, StreamTokenizer is used to
read either a string (sval) or a number (nval) as instance variables. The
Cin class is used for input from the keyboard and once it is compiled, the
class can be used in other applications as long as it is in the same
directory.
----------------------------------------------------------------------------------------
Demo this java script program to receive
extra points
import java.io.*;
public class Database {
private staticfinal int MAX = 100;
private Cin cin =new Cin();
private Stringname[] = new String[MAX];
private doublehourlyrate[] = new double[MAX];
private doublehoursworked[] = new double[MAX];
private doublegrosspay[] = new double[MAX];
private StringsearchName;
private StringfileName;
private int n =0;
public void load()throws IOException{
try{ Reader fi = new BufferedReader(
newInputStreamReader(
new FileInputStream("employee.dat")));
StreamTokenizer fin = new StreamTokenizer(fi);
int tokenType;
tokenType= fin.nextToken();
while((tokenType != StreamTokenizer.TT_EOF)){
name[n] = fin.sval;
fin.nextToken();
hourlyrate[n] = fin.nval;
fin.nextToken();
hoursworked[n] = fin.nval;
grosspay[n] = hoursworked[n] * hourlyrate[n];
tokenType = fin.nextToken();
n++;}//WHILE
}//TRY
catch(IOException ex){ System.out.println(ex); }//CATCH
}//LOAD
public voidinsert(){
System.out.print("Enter the employee name: ");
name[n] =cin.readString();
System.out.print("What is employee hourly rate? ");
hourlyrate[n]= cin.readDouble();
System.out.print("How many hours did theemployee work? ");
hoursworked[n]= cin.readDouble();
grosspay[n] =hoursworked[n] * hourlyrate[n];
n++;}//INSERT
public voiddisplay(){
for ( int i =0; i<n; i++ ){
if(name[i]!=""){
System.out.println( name[i] + " " + grosspay[i] );}//IF
}//FOR
}//DISPLAY
public boolean search(){
System.out.print("Enter the search name: ");
String searchName = cin.readString();
for(int i = 0; i < n; i++){
if ( searchName.equalsIgnoreCase(name[i])){
System.out.println("Found: "+name[i]);
System.out.println("Grosspay: "+grosspay[i]);
return true; }//IF
}//FOR
System.out.println("Name not found");
return true;
}//SEARCH
public boolean modify(){
System.out.print("Enter the search name: ");
String searchName = cin.readString();
for(int i = 0; i < n; i++){
if ( searchName.equalsIgnoreCase(name[i])){
System.out.print("What is employee hourly rate? ");
hourlyrate[i] = cin.readDouble();
System.out.print("How many hours did the employee work?");
hoursworked[i] = cin.readDouble();
grosspay[i] = hoursworked[i] * hourlyrate[i];
return true; }//IF
}//FOR
System.out.println("Name not found");
return false;
}//MODIFY
public boolean remove(){
System.out.print("Enter the search name: ");
String searchName = cin.readString();
for(int i = 0; i < n; i++){
if ( searchName.equalsIgnoreCase(name[i])){
name[i] = "";
return true; }//IF
}//FOR
System.out.println("Name not found");
return false;
}//REMOVE
public void quit() throws IOException{
this.store();
System.out.println("Thank you");
System.exit(0);
}//QUIT
public void store() throws IOException{
try{
FileOutputStream out = new FileOutputStream("employee.dat");
PrintStream ps = new PrintStream(out);
for(int i = 0; i < n; i++){
if ( name[i] != "" )
ps.println( name[i] + "\t" + hourlyrate[i] +
"\t" + hoursworked[i] );
}//FOR
out.close(); }//TRY
catch( IOException ex ){
System.out.println(ex); }//CATCH
}//STORE
public static void main( String args[] ) throws IOException{
Database db = new Database();
Cin read = new Cin();
db.load();
int choice = 0;
do{System.out.println("\t1-Insert");
System.out.println("\t2-Display");
System.out.println("\t3-Search");
System.out.println("\t4-Modify");
System.out.println("\t5-Remove");
System.out.println("\t6-Quit");
choice = read.readInt();
if( choice == 1 ) db.insert();
else if( choice == 2 ) db.display();
else if( choice == 3 ) db.search();
else if( choice == 4 ) db.modify();
else if ( choice == 5 ) db.remove();
else if ( choice == 6 ) db.quit();
else System.out.println("Enter correct number");
} while(true);
}//MAIN
}//DATABASE
-----------------------------------------------------------------------------------------------
Journal Monday April 16th, 2008
Subtopic of today:
What is Command Line Argument Management:
Argument c(argc), Argument v(argv)
How do you make Select Command from C++ with the
Command Line Argument.

Te
Final questions: 20pts each.
1-
Your task is to encrypt all sensitive data (security, privacy) in your database
and get rid of the original data (delete files or fields ). -The key for running
the encryption is "the quick brown fox jumps over the lazy dog". program is not
case sensitive, deal with special characters and numbers in your own creative
way. To test your program decrypt the data to get to original database. The test
data input is HELLO and the encrypted output you should get is PTFFB. Hint, you
may want to use an other key for numbers and special characters.
"the
quick brown fox jumps over the lazy dog"
abcdefghijklmnopqrstuvwxyz, skip letters that are repeated such as "o", "e"
2-
You are to design a database from scratch using any file access and memory
access mode (sequential, random, array, object, etc.) Be unique and creative.
You may want to use C++ or any programming language you are familiar with. show
your data file and queries.
3-
you are to design a database using access, DB2, Oracle, etc. Use your own SQL
query to access the similar data as in question two.
4-How
does the program on page 703 work if you can explain thoroughly. 20pts.
5-Why
should a manager be acquainted with database and its related issues. what is the
cost and benefits? (Pros/Cons) The format will be according to the management
article on www.ebrahimi.com
ex. The
research part of the essay is to get job description/requirements for manager
positions.
ex. from
essay format:
Why
Managers Should Become Better Acquainted
With Programming Issues, Web Source Code, and
Technology?
Alireza Ebrahimi, State University of New York,
College at Old Westbury, USA
Abstract
There has been a controversial debate over how well managers need to acquainted
with the area of information technology, especially about what managers need to
know of programming and understanding of web source code. Information is an
indispensable key to business success

Journal Monday
March 31st,
2008
Go to page 701 and Type and Run the program.


<HTML>
<BODY BGCOLOR=ffdeaa>
<CENTER><BR><B>Employee Database</B></CENTER><BR>
<HR WIDTH=65%>
<CENTER>Please select from the following choices:<BR><BR>
<FORM ACTION="insertrecord.html">
<INPUT TYPE="submit" VALUE="1. Insert a Record "></FORM>
<FORM ACTION="cgi-bin/displayall.cgi">
<INPUT TYPE="submit" VALUE="2. Display all Records "></FORM>
<FORM ACTION="search.html">
<INPUT TYPE="submit" VALUE="3. Search Database "></FORM>
<FORM ACTION="cgi-bin/update.cgi">
<INPUT TYPE="submit" VALUE="4. Update Record "></FORM>
<FORM ACTION="cgi-bin/delete.cgi">
<INPUT TYPE="submit" VALUE="5. Delete a Record "></FORM>
</CENTER></BODY>
</HTML>
--------------------------------------------------------------------------------------
<HTML>
<BODY BOCOLOR=FFDEAA>
<CENTER><BR><B>Employee Database</B></CENTER><BR>
<HR WIDTH=65%>
<CENTER>Please select from the following choices:<BR><BR>
<FORM ACTION=="insertrecord.html">
<INPUT TYPE="submit"VALUE="1. Insert a record "></FORM>
</CENTER></BODY>
</HTML>


Journal
Wednesday
March 26th,
2008
Q1- Your task is to encrypt all sensitive data (security,
privacy) in your database and get rid of the original data (delete files or
fields ). -The key for running the encryption is "the quick brown fox jumps over
the lazy dog". program is not case sensitive, deal with special characters and
numbers in your own creative way. To test your program decrypt the data to get
to original database. The test data input is HELLO and the encrypted output you
should get is PTFFB. Hint, you may want to use an other key for numbers and
special characters.(40 points)
"the quick brown fox jumps over the lazy dog"
abcdefghijklmnopqrstuvwxyz, skip letters that are repeated such as "o",
"e"
Q2- You are to design a database from scratch using any file
access and memory access mode (sequential, random, array, object, etc.) Be
unique and creative. You may want to use C++ or any programming language you are
familiar with. show your data file and queries.(30 points)
Q3- you are to design a database using access, DB2, Oracle, etc.
Use your own SQL query to access the similar data as in question two. (30
points)

ENCRYPTION EXAMPLE
Following is a sample PL/SQL program to encrypt data. Segments of the code are
numbered and contain
narrative text explaining portions of the code.
DECLARE
input_string VARCHAR2(16) := ’tigertigertigert’;
key_string VARCHAR2(8) := ’scottsco’;
encrypted_string VARCHAR2(2048);
decrypted_string VARCHAR2(2048);
error_in_input_buffer_length EXCEPTION;
PRAGMA EXCEPTION_INIT(error_in_input_buffer_length, -28232);
INPUT_BUFFER_LENGTH_ERR_MSG VARCHAR2(100) :=
’*** DES INPUT BUFFER NOT A MULTIPLE OF 8 BYTES ***’;
1. Test string data encryption and decryption-- The interface
for encrypting raw data is similar.
BEGIN
This is the beginning of the program
dbms_output.put_line(’> ========= BEGIN TEST =========’);
dbms_output.put_line(’> Input String :
’ ||
input_string);
BEGIN
dbms_obfuscation_toolkit. input_string => input_string,
key_string => key_string, encrypted_string =>
encrypted_string );
dbms_output.put_line(’> encrypted string : ’
||
encrypted_string);
dbms_obfuscation_toolkit.DESDecrypt(input_string =>
encrypted_string,
key => raw_key, decrypted_string =>
decrypted_string);
dbms_output.put_line(’> Decrypted output : ’
||
decrypted_string);
dbms_output.put_line(’> ’);
if input_string = here is an "if"
statement
decrypted_string THEN
dbms_output.put_line(’> DES Encryption and Decryption
successful’);
END if;
EXCEPTION
WHEN error_in_input_buffer_length THEN
dbms_output.put_line(’> ’ ||
INPUT_BUFFER_LENGTH_ERR_MSG);
END;

Each row (tuple) from the table is interpreted as follows: an
employee has a number, a name,
a job title and a salary. Furthermore, for each employee the
number of his/her manager, the
date he/she was hired, and the number of the department where he/she is
working are stored.







insert into
<table>
[(<column
i, . . . , column j>)]
<query>
create table
OLDEMP
(
ENO
number(4)
not null,
HDATE
date);
We now can use the table
EMP
to insert tuples into this new relation:
insert into
OLDEMP (ENO, HDATE)
select
EMPNO, HIREDATE
from EMP
where
HIREDATE <
’31-DEC-60’;



Journal Monday
March 24,
2008
Q1- Your task is to encrypt all sensitive data (security,
privacy) in your database and get rid of the original data (delete files or
fields ). -The key for running the encryption is "the quick brown fox jumps over
the lazy dog". program is not case sensitive, deal with special characters and
numbers in your own creative way. To test your program decrypt the data to get
to original database. The test data input is HELLO and the encrypted output you
should get is PTFFB. Hint, you may want to use an other key for numbers and
special characters.(40 points)
"the quick brown fox jumps over the lazy dog"
abcdefghijklmnopqrstuvwxyz, skip letters that are repeated such as "o",
"e"
Q2- You are to design a database from scratch using any file
access and memory access mode (sequential, random, array, object, etc.) Be
unique and creative. You may want to use C++ or any programming language you are
familiar with. show your data file and queries.(30 points)
Q3- you are to design a database using access, DB2, Oracle, etc.
Use your own SQL query to access the similar data as in question two. (30
points)
Journal Wednesday February 27,
2008
THIS
WORK BELOW IS DUE ON MONDAY FIRST 1/2 OF THE CLASS
- We will retake the test to the online and we will log on
to:
https://oldwestbury.sln.suny.edu/frames.aspx and log in.
1 -On
page 297 run the program as is FIRST
2 -Change this so
it becomes a Membership Database such as username and password.
3 - Encrypt the
password before saving it to the file.
Today we will show you a
program in Dev C++ from page 297.

Each student should
reproduce the program on their own workstation. The program above
does not have all of the functions declared and will not compile.
Below is version 2
of the program with all of the functions coded.
#include<iostream>
using namespace std;
char rfappend(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfdisplay(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfsearch(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfmodify(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfdelete(){
cout<<"Append Under Construction "<<endl;
return 0;
}
main(){char option;
cout<<"SELECT ONE OF THE FOLLOWING "<<endl;
cout<<"\t TYPE 1 TO INSERT "<<endl;
cout<<"\t TYPE 2 TO DISPLAY "<<endl;
cout<<"\t TYPE 3 TO SEARCH "<<endl;
cout<<"\t TYPE 4 TO MODIFY"<<endl;
cout<<"\t TYPE 5 TO DELETE "<<endl;
cout<<"\t TYPE # TO QUIT "<<endl<<endl;
cin>>option;
switch(option){
case '1': rfappend();
break;
case '2': rfdisplay();
break;
case '3': rfsearch();
break;
case '4': rfmodify();
break;
case '5': rfdelete();
break;
case '#': cout<<"BYE "<<endl;
exit(1);
break;}//SWITCH
system ("Pause");
return 0;
}
Testing our program...

Testing is VERY
important. Many databases and programs are not tested enough.
Make your messages
friendly and clear.

#include<iostream>
using namespace std;
char rfappend(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfdisplay(){
cout<<"Display Under Construction "<<endl;
return 0;
}
char rfsearch(){
cout<<"Search Under Construction "<<endl;
return 0;
}
char rfmodify(){
cout<<"Modify Under Construction "<<endl;
return 0;
}
char rfdelete(){
cout<<"Delete Under Construction "<<endl;
return 0;
}
main(){char option;
while(1){
cout<<"SELECT ONE OF THE FOLLOWING "<<endl;
cout<<"\t TYPE 1 TO INSERT "<<endl;
cout<<"\t TYPE 2 TO DISPLAY "<<endl;
cout<<"\t TYPE 3 TO SEARCH "<<endl;
cout<<"\t TYPE 4 TO MODIFY"<<endl;
cout<<"\t TYPE 5 TO DELETE "<<endl;
cout<<"\t TYPE # TO QUIT "<<endl<<endl;
cin>>option;
switch(option){
case '1': rfappend();
break;
case '2': rfdisplay();
break;
case '3': rfsearch();
break;
case '4': rfmodify();
break;
case '5': rfdelete();
break;
case '#': cout<<"BYE "<<endl;
exit(1);
break ;
default: cout<<"Enter 1 to 5"<<endl;
}//SWITCH
}//WHILE
system ("Pause");
return 0;
}
The code with the append function
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
char rfappend(char personname[], char phone[]){
ofstream fout("directory.in",ios::app);
cout<<"ENTER PERSON NAME ";
cin>>personname;
cout<<"ENTER THE PHONE NUMBER ";
cin>>phone;
fout<<personname<<setw(20)<<phone<<endl;
fout.close();
return 0;
}
char rfdisplay(char personname[], char phone[]){
ifstream fin ("directory.in");
while (fin>>personname>>phone){
cout<<"PERSON NAME IS "<<personname<<endl<<endl;
cout<<"PHONE IS "<<phone<<endl<<endl; }//WHILE
fin.close();
return 0; }
char rfsearch(){
cout<<"Search Under Construction "<<endl;
return 0;
}
char rfmodify(){
cout<<"Modify Under Construction "<<endl;
return 0;
}
char rfdelete(){
cout<<"Delete Under Construction "<<endl;
return 0;
}
main()
{char personname[100], phone[10],option;
while(1){
cout<<"SELECT ONE OF THE FOLLOWING "<<endl;
cout<<"\t TYPE 1 TO INSERT "<<endl;
cout<<"\t TYPE 2 TO DISPLAY "<<endl;
cout<<"\t TYPE 3 TO SEARCH "<<endl;
cout<<"\t TYPE 4 TO MODIFY"<<endl;
cout<<"\t TYPE 5 TO DELETE "<<endl;
cout<<"\t TYPE # TO QUIT "<<endl<<endl;
cin>>option;
switch(option){
case '1': rfappend(personname,phone);
break;
case '2': rfdisplay(personname,phone);
break;
case '3': rfsearch();
break;
case '4': rfmodify();
break;
case '5': rfdelete();
break;
case '#': cout<<"BYE "<<endl;
exit(1);
break ;
default: cout<<"Enter 1 to 5"<<endl;
}//SWITCH
}//WHILE
system ("Pause");
return 0;
}
This program will send out the input to a file called directory.in.
Binary vs. Text files
Binary files are used to store executable code, Text Files are used to store
raw text from the system.
For Last year notes : Class notes
Journal Monday February 25,
2008
After you finish answering the questions Email to:
ebrahimidr@gmail.com
Name______________________________________
T /
F 1) A database has operations such as storing, displaying, and searching for
records.
T /
F 2) A file should be closed before it is opened again for another operation
mode.
T /
F 3) A file can be accessed sequentially as well as randomly.
T /
F 4) The most efficient way to delete from a file is to copy the entire file,
excluding deleted data.
T /
F 5) Random access becomes faster if each record has a fixed length with a
unique key.
T /
F 6) Binary files store the binary value of a number instead of its ASCII value.
T /
F 7) Modification is more difficult in arrays rather than in a sequential file.
T /
F 8) It is better to store large amounts of data into an array rather than into
a file.
T /
F 9) Information in an array will be lost after the program terminates.
T /
F 10) In sequential files, modification requires duplication of the existing
file.
T /
F 11) A data file is a file in which data is stored and from which data is
retrieved.
T /
F 12) In random access there is no need for duplication of the file when
deleting a record.
T /
F 13) When deleting a record from an array, the physical storage will be
deleted.
T /
F 14) It is necessary to shuffle an array upon deletion to make the insertion
faster.
T /
F 15) If the array is not shuffled after deletion, it is necessary to indicate
that the record was deleted.
T /
F 16) A Database is a
collection of unrelated data.
T /
F 17) One person having many credit cards is an example of a many-to-many
relationship.
T /
F 18) The most important function in a database is delete.
T /
F 19) A database can have at most one table.
T /
F 20) The importance of normalization of a database is to create more memory for
redundancy of data.
=====================================================================================
T /
F 21) Simple file encryption can be done by changing ASCII values or by using an
associate array.
T /
F 22) Overtime pay computation is a function of select command and SQL reports
are an example of database manipulation.
T /
F 23) A database report is used by managers to enter new records to a database.
T /
F 24) Add (append) , Delete (purge), Modify (update), and Search are all
functions of operating systems.
T /
F 25) The interaction between you and your computer is also known as an
interface.
T /
F 26) Three categories
of data models are conceptual, physical, and implementation.
T /
F 27) A database schema
includes descriptions of the database structure and the constraints that should
hold on the database.
T / F 28) C++ is an example of a DBMS language.
T / F 29) A primary key is necessary to uniquely identify a record in a table; two records may have the same value in the field designated as primary key.
T / F 30) Creating relationships between tables increases data redundancy and makes a database less efficient.
T / F 31) When input data becomes large, it is necessary to work with a data file rather than typing it.
T / F 33) Unicode consists of 32 bits.
T / F 34) A database consists of infinite fields.
T / F 35) A load function will read all records from a file into an array and should be called at the start of a program.
T /
F 36) ifstream
fin(“data.txt”,ios::in); if(!fin) cout<<”NO FILE”; will test the file’s
existence.
T /
F 37) A file can be
opened for both input and output such as fstream fout(“data.dat”,
ios::in|ios::out);
T /
F 38) “del” and “rename” in C++ which are to delete and rename a file, are
equivalent to “rm” and “mv” which are in Linux or Unix.
T /
F 39) A binary search is fastest for searching a large unsorted data file.
T /
F 40) Database validation of user input is necessary for fields such as phone
number and social security to ensure data integrity.
T /
F 41) Sequential search is preferred over hashing because of the speed.
T /
F 42) The C++, system( )
function enables the programmer to use operating system commands.
T /
F 43) In a random access
file, seekg( ) is used for putting data and seekp( ) is used for getting data.
T /
F 44) Most of today’s databases interact with the user and then access the data
file to search and to perform the necessary operations.
T /
F 45) A table in a relational database is a predefined format of rows and
columns that define an entity.
T /
F 46) Examples of databases are WindowsNT, UNIX, DB2, MYSQL, and Solaris.
T /
F 47) You can create CGI web databases using the following programming
languages: C/C++ and Perl.
T /
F 48) The three example databases are Access, SQL, and Oracle.
T / F 49) In a database, a
table contains records, records contain fields, fields contain characters, a
character contains a byte or two.
T / F 50) Encryption is
essential when working with databases to keep information unaccessible.
=====================================================================================
T / F 51) A bite has a single
binary value, either 0 or 1.
T / F 52) FUZZY logic has more than two
states.
T / F 53)By using a
linked list the deleted record will be physically deleted.
T /
F 54)A relational database is a collection of organized data that are related
between its
various data members.
T / F 55) A byte is the smallest addressable unit of data in a computer.
T / F 56) A database can be made in any language such as C++, Java, Visual
Basic, or JavaScript.
T / F 57) The interaction between you and your computer is also known as an
interface.
T / F 58) C++ is the foundation for the most popular database application on the
Internet.
T / F 59) The three example databases are Adobe, PowerPoint, and Microsoft Word
T / F 60) An example of Data Manipulation\Reporting in a Payroll\Bank Database
is an overtime pay report.
T / F 61) There have been as many as 9,000 deaths as a result of medical
database errors each year.
T / F 62) Ingres is a database under windows operating systems.
T / F 63) Primary key is used in relational databases to uniquely identify
records.
T / F 64) For a database security is more important than access.
T / F 65) Database Normalization is used to minimize duplication of information.
T / F 66) The main functions of the database are: create, read, update,
duplicate, and delete.
T / F 67) A key feature of the computer is the ability to store information, and
to retrieve it at a later time.
T/F
68) The important commands of SQL are select, update, and purge.
T/F
69) The Assignment for this class is to design a Web interface.
T/F
70) To create a database interface you must use Oracle.
T/F 71) In order to design a database with access it must be specified the
length and type of each field.
T/F
72) In Unicode the value of 'A' is 65 and 'a' is 97.
T/F
73) It is possible to create a database on Web by using CGI.
T/F
74) The most important function of a database is the search function.
T/F
75) It is possible to retrieve deleted records from a database.
Journal
Wednesday February 20, 2008
Next
class we will have our first quiz. all questions by us. please Email to
ebrahimidr@gmail.com
Please have questions
from all areas covered, Test will be on Monday 25th 2008 100 T/F Questions.
Most questions in this example are from
chap. 9 That are important for a strong foundation of database
1- First copy and paste the questions from the
website to a blank page.
2- Answer all questions and Email them to
ebrahimidr@gmail.com
3- Copy this to your wcm Exam Webpage.
Today we will discuss backing up your
database.
Page 291-292 functions:
WHAT IS A DATABASE (dbase)
Manipulating data (information) plays an important role in any organization
today. In order to manipulate the data, information has to be stored, retrieved,
modified or deleted. At any moment new data can be added to a file, or existing
information can be retrieved, modified or even deleted. Instead of one file
there might be several files needed to store information as well as to interact
with other files (file processing). The notion of data manipulation where data
may be stored, retrieved, modified or even deleted is called a database.
In addition, there are times when it is necessary to generate reports based on a
certain request or computations from the database.
A
JOURNEY FROM BIT TO DATABASE
Computer
information is represented in binary form using a bit. Each bit contains a
value which is either zero or one. Eight bits represent a byte. Depending on the
system one or two bytes represent a character. Several characters form a field
or a string. One or more fields make up a record. Multiple records build a
stream or a file. Finally several files create a database. However this naming
convention may vary slightly, a string may represent the whole file or a
database may contain only a single file.
BUILDING A SIMPLE DATABASE: Create, Display and Search
The
following program illustrates how easily you can build a simple database by
putting a few functions together. For the sake of simplicity, the database
program will add, display and search the data immediately, with data
modification and deletion performed later. In writing this program, the concern
is simplicity rather than efficiency (speed of program or saving space). The
three functions for this database are myappend() to add a record to the
end of data file, mydisplay() to display entire records, and mysearch()
to search for a particular record.
MODE OF OPENING A FILE
A file can be opened according to the following ways
(modes):
A file can be opened as an input file so that data can be
retrieved.
ifstream fin (“data.in”,ios::in);
The default file mode for ifstream is ios::in
ifstream fin (“data.in”); //input stream
A file can be opened so that data can be written or output
to it.
ofstream fout (“data.out”,ios::out);
The default file mode for ofstream is ios::ou
ofstream fout (“data.out”);
In addition a file can be for output by adding (appending)
data to the end of the existing file.
ofstream fout (“data.out”,ios::app);
A file can be for both input and output ios::in | ios::out
fstream fout (“data.dat”, ios::in|ios::out);
Ruan contribution for today program
from page 292.
#include<fstream>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<stdlib.h>
using namespace std;
int myappend(char personname[],char phone[]){
ofstream fout("directory.txt",ios::app);
cout<<"ENTER PERSON NAME";
cin>>personname;
cout<<"Enter THE PHONE";
cin>>phone;
fout<<personname<<setw(20)<<phone<<endl;
return 0; }// MyAppend
int mysearch(char personname[],char phone[]){
char searchname[20];
ifstream fin("directory.txt",ios::in);
cout<<"ENTER THe Search Name";
cin>>searchname;
while(fin>>personname>>phone){
if(strcmp(searchname,personname)==0){
cout<<"THE PHONE IS" <<phone<<endl<<endl;
return 1; } //if
}// while
cout<<"NAME NOT FOUND" <<endl;
return 0; } //MYSearch
int mydisplay(char personname[],char phone[]){
ifstream fin("directory.txt");
while(fin>>personname>>phone){
cout<<"PERSON NAME IS" << personname<<endl;
cout<<"PHONE IS " <<phone<<endl; }//while
return 0; } // My Display
main(){
char option;
char personname[20],phone[20];
cout<<"Select One Of The Following" << endl;
while(1) { cout<<"TYPE 1 TO INSERT" <<endl;
cout<<"TYPE 2 TO Display" <<endl;
cout<<"TYPE 3 TO Search" <<endl;
cout<<"TYPE # TO Quit" <<endl;
cin>>option;
if(option =='1')myappend(personname,phone);
else if (option=='2') mydisplay(personname,phone);
else if (option=='3') mysearch(personname,phone);
else if (option=='#') {cout<<"BYE"<<endl;exit(1);} } //while
return 0;
}//Main



YEAR 2007 NOTES
Class notes
Journal Wednesday February 13,
2008
Please have questions
from all areas covered, Test will be on Monday 25th 2008 100 T/F Questions.
Most questions in this example are from
chap. 9 That are important for a strong foundation of database
This is an example of last years test
please try to use all topics covered in the semester.
BU 5010 Database Applications
for Managers
Quiz
1 True / False
Spring 2007
Name______________________________________
T /
F 1) A database has operations such as storing, displaying, and searching for
records.
T /
F 2) A file should be closed before it is opened again in another operation
mode.
T /
F 3) A file can be accessed sequentially as well as randomly.
T /
F 4) The most efficient way to delete from a file is to copy the entire file,
excluding deleted data.
T /
F 5) Random access becomes faster if each record has a fixed length with a
unique key.
T /
F 6) Binary files store the binary value of a number instead of its ASCII value.
T /
F 7) Modification is more difficult in arrays rather than in a sequential file.
T /
F 8) It is better to store large amounts of data into an array rather than into
a file.
T /
F 9) Information in an array will be lost after the program terminates.
T /
F 10) In sequential files, modification requires duplication of the existing
file.
T /
F 11) A data file is a file in which data is stored and from which data is
retrieved.
T / F 12) In random access file there is
no need for duplication of the file when deleting a record.
Answer: True there is no need for duplication.
- Give me one example of deleting a file of
database and why?
Answer: A student must be deleted from active
students after they graduated
- If you have a cassette tape containing two
song and you need to delete song one how will you do it?
Answer: copy the song one into a blank cassette
tape, if you deleted from the tape you would have a blank gap for the
length of the song.
What is a Random Access?
Answer: A CD is a random access
T /
F 13) When deleting a record from an array, the physical storage will be
deleted.
T /
F 14) It is necessary to shuffle an array upon deletion to make the insertion
faster.
T /
F 15) If the array is not shuffled after deletion, it is necessary to indicate
that the record was deleted.
T /
F 16) A Database is a
collection of related data.
T /
F 17) One person having many credit cards is an example of a many-to-many
relationship.
T /
F 18) The most important function in a database is delete.
T /
F 19) A database can have at most one table.
Answer: False - At least one table
T / F 20) The importance of
normalization of a database is to eliminate waste of memory and redundancy of
data.
Database
normalization,
sometimes referred to as
canonical synthesis,
is a technique for designing
relational database
tables
to minimize duplication of information and, in so doing, to
safeguard the database against certain types of logical or
structural problems, namely data anomalies. For example, when
multiple instances of a given piece of information occur in a
table, the possibility exists that these instances will not be
kept consistent when the data within the table is updated,
leading to a loss of
data integrity.
A table that is sufficiently normalized is less vulnerable to
problems of this kind, because its structure reflects the basic
assumptions for when multiple instances of the same information
should be represented by a single instance only.
Higher degrees of
normalization typically involve more tables and create the need
for a larger number of
joins,
which can reduce
performance.
Accordingly, more highly normalized tables are typically used in
database applications involving many isolated
transactions
(e.g. an
Automated teller machine),
while less normalized tables tend to be used in database
applications that do not need to map complex relationships
between data entities and data attributes (e.g. a reporting
application, or a full-text search application).
Database theory
describes a table's degree of normalization in terms of
normal forms
of successively higher degrees of strictness. A table in third
normal form (3NF),
for example, is consequently in second normal form (2NF)
as well; but the reverse is not always the case
T / F 21) Simple file encryption can be
done by changing ASCII values or by using an associate array.
Answer: True The sensitive material
should always be encrypted. This is Part of Internet security.
ASCII
American Standard Code for Information
Interchange
T /
F 22) A data file is an executable file that performs a database function.
T /
F 23) A database report is used by managers to enter new records to a database.
T /
F 24) A Database
Designer’s responsibility is to define the content, the structure, the
constraints, and functions or transactions against the database.
T /
F 25) A set of concepts
to describe the structure and the constraints of a database is called a data
object.
T /
F 26) Three categories
of data models are conceptual, physical, and implementation.
T /
F 27) A database schema
includes descriptions of the database structure and the constraints that should
hold on the database.
T / F 28) C++ is an example of a DBMS language.
T / F 29) A primary key is necessary to uniquely identify a record in a table; two records may have the same value in the field designated as primary key.
T / F 30) Creating relationships between tables increases data redundancy and makes a database less efficient.
T / F 31) The proper C++ code to open a text file is:
ifstream
studentFile("students.txt", ios::in);
T / F 32) In C++, the syntax code if (!fin) can be used instead of if (fin==NULL).
T / F 33) Unicode consists of 8-16 bits.
T / F 34) A database consists of many fields.
T / F 35) A load function will read all records from a file into an array and should be called at the start of a program.
T /
F 36) ifstream
fin(“data.txt”,ios::in); if(!fin) cout<<”NO FILE”; will test the file’s
existence.
T /
F 37) A file can be
opened for both input and output such as fstream fout(“data.dat”,
ios::in|ios::out);
T /
F 38) ofstream
outfile(“data.txt”, ios::noreplace); prevents an existing file from being
overwritten.
T /
F 39) A binary search is fastest for searching a large unsorted data file.
T /
F 40) Database validation of user input is necessary for fields such as phone
number and social security to ensure data integrity.
T /
F 41) Sequential search is preferred over hashing because of the speed.
T / F 42)
The
C++ system( ) function enables the programmer to use operating system commands.
Answer:
This
are some known operating systems Windows , Solaris Sparc, Solaris Intel , QNX ,
OS/2 , MacOS , Linux Sparc, Linux PowerPC, Linux i386, FreeBSD i386 , BeOS
T /
F 43) In a random access
file, seekg( ) is used for putting data and seekp( ) is used for getting data.
T /
F 44) Access will not allow you to create a one to many relationship due to
security.
T /
F 45) Semantic databases are based on the grammar of the expression.
T /
F 46) ifstream
fin(“data.txt”, ios::in); associates a file for output access.
T /
F 47) You can create CGI web databases using the following programming
languages: C/C++ and Perl.
T /
F 48) The three example databases are Access, SQL, and Oracle.
T / F 49) In order for a C++
database program to read from a textfile it is not necessary to use; #include<fstream>.
T / F 50) In a C++ database
program, it is not required that you include the name of the textfile, in order
for the program to locate it and access the data.
T / F 51) A software package/
system to facilitate the creation and maintenance of a computerized database is
known as DBA.
T / F 52)A DBMS doesn’t involve in any sort of program security or do
any active processing.
T / F 53) A set of concepts to describe
the structure of a database, and certain constraints that the database
should obey is known as Data Model Operations.
T / F 54) An entity is an object that is
distinguishable from other objects by a specific set of attributes.
T / F 55) Using
write( ) function from <fstream>, one can write an entire structure
(record) to a file.
T / F 56)By using a
linked list the deleted record will be physically deleted.
T /
F 57) Conceptual
data models describe details of how data is stored in the computer.
T /
F 58) The Entity Relationship Model consists of entities with no possible
relation to each other.
T /
F 59) In the Object Oriented Model, objects consist of data operations on the
data.
T /
F 60) The physical implementation of your database files at the lowest level is
specified at the conceptual level.
On the Department of Health and Human Services website-
The very critical issues of medical errors and patient safety have received a
great deal of attention. In November 1999, the Institute of Medicine (IOM)
released a report estimating that as many as 98,000 patients die as the result
of medical errors in hospitals each year. (http://www.ahrq.gov/qual/errorsix.htm)