44. Recap - Agnivo102/Database_Architect GitHub Wiki

Computer in its fundamental:

The hardware which is a set of electric pathways which does the calculation, a memory which only holds data when the machine is working and a hard disk which stores data all the time even when the machine shut down.

Comparison of database architecture with real world scenario:

To compare a working database in real world we need to visualize a shop. What does a shop has - it has the things they sell, people who does the work and many different records like a record to keep track of their investory, records to track their daily sales etc. A database is much similar to that.

Server Process:

Imagine we went to a shop and ask the shopkeeper of their assistant that we need this thing. So first they will looo at our request and determine whether their shop has this thing or not, if they have then they will determine whether they should sell this thing to the buyer or not. If all these checks have passed they will search their shop for the thing. If they find it they give us the goods. If they don't find it they go to their warehouse and bring the goods from there to give us. Its same as to how server process works. For example we run a select statement, the server process after doing the syntax check and sementic checks (similar to how th3 shopkeeper will check) will go to optimizer which will first search the database buffer cache, if they find it then they give user the output, if ot doesn't then it will go to the data files and bring the required data block to give the user the details.

Instance:

The literal meaning of instance is like a specific case or presence. In database the instance is the fusion of System Global Area and Background processes. If we compare it to its real world meaning, it would be the presence of database in RAM. As the database is logical it has no presence when it is in shutdown. After starting up it is finally present in the RAM. As for why it is the fusion of SGA and Background Processes, SGA is basically the database's logical structure structure created in the RAM, and Background Processes is the bridge between the RAM and the database files (data files, control files etc) in the physical memory. So the SGA and the Processes like LGWr or CKPT both together creates the presence of the database.

System Global Area:

As for why it's called the System Global Area. The name system area is pretty obvious as its basically the logical structure of the database created in the RAM. As for why it is global, its because when multiple users logs in to the database the System Global Area is shared between all of them. So it also has the word global in it.

Importance of Redo Log and Archive Log Files:

We know that when any DML statement is run in the database, i,e any change is made to the physical data in the data files those DML statements is written into the Redo Log, and finally in the archive log Files. As for why-

Now visualize a real world scenario. You have gone to the bank and made a deposit in your account. The bank official commits the transaction, but before the changes is made to the data file by the DBWr the server suddenly crashes. What will happen this? The change which was commited to the database was not completed then. Naturally the customer won't accept the explanation that the server shut down in that moment.

So for this - when any DML statement is run in the system that statement is first written into the process LGWR (this was even before then statement is commited), then when the statement is commited the first thing that is done is the commited DML statement is written in the Log file by the Log Writter process, the finally the changes are made to the data file and control file (i,e the SCN number addition in the control file). So as the DML statement is stored in the redo log file, if the server crashes before any charges could be made on the files, that can easily be recovered.

Importance of the Checkpoint background process:

The literal meaning of the word Checkpoint is checking or verifying in a place. Now think about a scenario. You have gone to a foreign country but you have lost your passport. The passport was checked at the airport and then at the hotel. Those 2 events are the Checkpoint. As you or the investigator knows the passport was checked in those places at this point of time, the are sure it didn't get lost before then. So they can focus of what happened after that rather than uselessly trying to find the passport in the airport. That can be done because the Checkpoint information was present.

Now how this is translated in the database. We know after a commit is done the Checkpoint information is saved on the header of the datafile and the control file. So if any data get lost we can use that information for the recovery of that specific data. An example of this is Incomplete Recovery. Thats can be done because the control file has the checkpoint information of the SCN number before the deletion happened.

Logical Corruption:

Like in real world, I am doing a work in a file, then in the way I leave because of some other work and didnt write what I was suppose to write, then after returning I find that I didnt remember what I was writting. This will get the data inside get jumbled up, while the

Instance Corruption: