Different Programming approaches:
- functional (LISP, ML)
- Procedural (Pascal, C)
- Modular
- Object – Oriented
Functional: Based on the principle of using functions to manipulate symbol expressions (functions take one or more items of data (symbolic expressions), process the data and outputs a single value from the data manipulation as a result
Procedural: Based on algorithmic solutions and procedures, which are applied to data structures (used widely, highly effective but major problem: integration of different parts of a system when many developer work on the system.
Modular: Programs are constructed from smaller component parts called modules.
Object Oriented: extension of modular programming (Java, C++) – representations of data and algorithms that are to be manipulated are packaged together into programming structures called objects. These are derived from templates called Classes. Features: 1.Object can be created from classes. 2.Classes in turn can be combined together in a number of different ways, including inheritance. 3.Inheritance is a method for constructing a complex class by combining simpler classes that have been constructed previously.
Stepwise refinement: take the specification and turning it into a program: outline the major steps required by your program until you reach the point where a sub-step would correspond to a statement into your program. (pseudocode)
Errors:
1.Compile time errors (syntax errors).
2. Run time errors (logical errors)
– input not being entered correctly
– routines that process the input including incorrect calculations.
– logical flow of the program being incorrect.
– sections of the program outputting the results displaying the information.
Providing test plans: state the purpose of the test, state the input, expected output, actual output.
Main function of the program: process and manipulate information.
Information in programs is manipulated in program statements called expressions
– expressions: taken from operand and operator ( + – / *, etc)
– variables: any operand can be replaced by another type of operand called a variable. ( containers for data)
– constant variables: single unchangeable value
Data types:
– integers. (integer number)
– real numbers (floating point numbers)
– pieces of text (strings)
– logical values (Booleans) – true or false, logical operators + comparison operators.
Program control structures: 1. repetition 2. selection.
Repetition:
– FOR: when you know how many times the loop will be repeated.
– DO WHILE: when the number of repetitions for the loop is unknown.
– REPEAT UNTIL: terminating conditions is checked at the end of the loop.
Selection: IF THEN ELSE.
Passing parameters: by value / reference
Passing by value: the value of the variable being passed is copied and given to the variable specified in the parameter list. The value is not affecting the other value in the other procedures.
Adv: restrict the chances of variables being changed unintentionally
Disadv: extra memory + time is needed to store copies of all data.
Passing by parameters: the value of variable being passed is not copied, instead the variable in the parameter list is “linked” to the original variable; if any changes are made to the values of variables listed in the parameter list, the values of the variables passed will also be affected.
Making your program easy to understand:
- putting comments in your program.
- using meaningful variable and procedure names
- breaking the program down into meaningful subtask
- creating program layout by alignment (indentation), prgrm statements and space.
How we develop DBMS: ANSI / SPARK model
- external level: represents the way data is viewed by individual users.
- conceptual level: represents the logical (inherent) structure of data
- internal level: represents the way data is physically constructed.
CODD (1970) A relational database is a database that is perceived by the user as a collection of normalized relations of assorted degrees.
DBMS consist: data, software, hardware, users.
Database protection including: recovery, concurrency control, security, system recovery is based on transaction recovery (commit, rollback transaction)
Concurrency control: locking mechanism: x – exclusive (only one transaction at a time can hold such a lock on a specific row. s – shared (more than one transaction at a time can hold such a lock on a specific row, it’s used when data is read.
LAN (local area network) topologies:
Star: highly fault tolerant: break in the network cabling will only disable one computer.
Bus: requires less wiring than a star, but it is completely disabled if the network cable is cut (Ethernet)
Ring: ring has the same problem as a bus, but it is easier to coordinate.
Repeater: a repeater connects two LAN cables together by monitoring the signals on a cable and transfers an amplified copy of the signal onto the other cable to which it is interlinked. There’s no intelligence in a repeater; it is merely a simple copying device (to some extent, the error is also propagated.)
Bridges: connects 2 LANs together, bridges can identify individual frames, reduces the propagation of errors across joined LANs.
Switches: a bridge with many LANs connected to it, very fast multiport bridge – adv: flexibility.
COMER (1997): a packet switch is the basic building block of WAN (Wide Area Networks.) a WAN is formed by interconnecting a set of packet switches and then connecting computers. Additional switches or interconnections can be added as needed to increase the capacity of the WAN.
Control information composed of 2 parts:
– specifies the destination station.
– Next switch that the packet should be sent to on its way to the destination station.
Each switch in the network contains routing table: consist every destination station address that exists in the WAN and the address of the next location that a packet must be sent to reach that destination.
Routing table requirements:
– Universal routing: must have an entry for every possible destination station, each entry must indicate the next switch to which the packet must be forwarded.
– Optimal rules: next switch indicated must be the next step on the shortest path to the packet’s destination. (Dijkstra’s Algorithm)
COMER (1997): An agreement that specifies the format and meaning of message computer exchange is known as a communication protocol. Application programs that use a network do not interact directly with the network hardware. Instead an application interacts with protocol software that follows the rules of a given protocol when communicating.
7 Layer reference model: Physical, Network, Transport, Session, Presentation, Application.
A router is a specific purpose computer dedicated to the task of interconnecting networks. A router can interconnect networks that use different technologies including different media, physical addressing schemes or frame formats.
An internet consists of a set of networks interconnected by routers. The internet scheme allows each organization to choose the number or type of networks. The number of routers to use to interconnect them and the exact interconnection topology.
A communication protocol must then (TCP/IP)
1. translate the data into packets
2. translate the packets into frames.
3. map the virtual network address onto real physical address.
4. route the data between computers across various linking networks.
TCP/IP’s layer: Physical, Network interface, Internet, Transport, Application layers.
IP: Internet Protocol: responsible for making sure those packets are sent to their intended destination. (covers physical layer, network interface and internet)
TCP: Transport Control Protocol: Implement the above reliability requirements by adding acknowledgement to the IP communication process. (guarantees no packet duplication/loss)
A server is a networked application that waits for a client to begin a relationship with it, services the needs of the client and then ends the relationship. Transport layer of TCP/IP uses 16bit numbers called protocol port numbers or ports to define a series of “entry” points to a computer.
Communication occurs by a networked application (a client) sending a message (a packet) to the transport layer software with an address designating the destination computer and the port that the destination network application (the server) is connected to. A networked application waiting for communication effectively “listens” to a port until a packet is passed to the port via the transport layer software.
A DNS server is effectively a reference table that contains the names and corresponding IP addresses of a particular domain. Each domain has a DNS service, and all DNS servers are linked in a hierarchy, which reflects the hierarchy of the DNS. Each networked application will know the IP address of the local domain’s DNS server. When a networked application wishes to find the IP address of a domain name, it will send a request to the local DNS server. The DNS server will attempt to translate the name. If it cannot, it passes the request up the hierarchy to the DNS server of the next highest level. Request are passed up and down the DNS hierarchy until a translation IP address is found. The DNS service then replies with this information to the requesting networked application. The application can then proceed with sending the original message. The use of a hierarchy of DNS servers prevents the congestion of a dingle server.
- A relation is in 1NF if it contains no repeating groups
- To convert an unnormalised relation to 1NF either:
- Flatten the table and change the primary key, or
- Decompose the relation into smaller relations, one for the repeating groups and one for the non-repeating groups.
- Remember to put the primary key from the original relation into both new relations.
- This option is liable to give the best results.
Summary: 2NF
- A relation is in 2NF if it contains no repeating groups and no partial key functional dependencies
- Rule: A relation in 1NF with a single key field must be in 2NF
- To convert a relation with partial functional dependencies to 2NF. create a set of new relations:
- One relation for the attributes that are fully dependent upon the key.
- One relation for each part of the key that has partially dependent attributes
Summary: 3NF
- A relation is in 3NF if it contains no repeating groups, no partial functional dependencies, and no transitive functional dependencies
- To convert a relation with transitive functional dependencies to 3NF, remove the attributes involved in the transitive dependency and put them in a new relation
- Rule: A relation in 2NF with only one non-key attribute must be in 3NF
- In a normalised relation a non-key field must provide a fact about the key, the whole key and nothing but the key.
- Relations in 3NF are sufficient for most practical database design problems. However, 3NF does not guarantee that all anomalies have been removed.
Read Full Post »