Database-MySQL [3i Infotech Placement]: Sample Questions 24 - 25 of 162

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 24


Describe in Detail


What is E-R model?


  • An entity-relationship model (ER model) is a systematic way of describing and defining a business process.
  • An ER model is typically implemented as a database.
  • The main components of E-R model are: entity set and relationship set.

    The geometric shapes and their meaning in an E-R Diagram -

    • Rectangle: Represents Entity sets.
    • Ellipses: Attribute
    • Diamond: Relationship Set
    • Lines: They link attributes to Entity Sets and Entity sets to Relationship Set
    • Double Ellipses: Multivalued Attributes
    • Dashed Ellipses: Derived Attributes
    • Double Rectangles: Weak Entity Sets
    • Double Lines: Total participation of an entity in a relationship set

A sample E-R Diagram:

The Sample of E-R Diagram

Question 25


Describe in Detail


How to create a database link?


  • First, create a database link, which points to the other location. The database link can be created with a command similar to the following:

    CREATE DATABASE LINK other_db CONNECT TO scott IDENTIFIED BY tiger USING ‘tns_alias’ ;

  • Use the appropriate user ID and password to connect to the remote database, and configure your TNSNAMES. ORA file with a TNS alias to point to that database.
  • You can test the database link with a simple query, such as the following:

    SELECT sysdate FROM dual@other_db;

  • The@other_db clause uses the database link you created.
  • If the query returns the date, then the link works properly.
  • Once the link is set up, you can either issue a command to modify the data in the remote database when you modify the local database or you can use a database trigger.
  • For instance, if the application modifies the local database by performing an INSERT similar to the following:

    INSERT INTO my_table VALUES (1, ‘Two’ ) ;

  • Then you can also code another SQL statement to insert the same values across a database link.

    INSERT INTO my_table@other_db VALUES (1, ‘Two’ ) ;

  • Additionally, you can create a trigger.

CREATE TRIGGER modify_remote_my_table BEFORE INSERT ON my_table BEGIN INSERT INTO my_table@other_db VALUES (: new. colA, : new. colB) ; END; /

Developed by: