Posts

Showing posts from August, 2018

MongoDB queries for CRUD operation

root@localhost student1]# systemctl start mongod [root@localhost student1]# mongo MongoDB shell version: 2.4.6 connecting to: test > show dbs TE     0.203125GB company      0.203125GB local 0.078125GB tecomp       0.203125GB > use shubhangi switched to db shubhangi > show collections > db.createCollection("information") { "ok" : 1 } > db.information.insert({"rollno":101,"name":"shubhangi","marks":85}); > db.information.insert({"rollno":102,"name":"Itisha","marks":90}); > db.information.insert({"rollno":103,"name":"ram","marks":88}); > db.iformation.find() > db.information.find() { "_id" : ObjectId("59b8ba5dc1991a8ea9ff1dea"), "rollno" : 101, "name" : "shubhangi", "marks" : 85 } { "_id" : ObjectId("59b8bacbc1991a8ea9ff1deb&

Java Mysql Connectivity Code

import java.sql.DriverManager; import java.sql.ResultSet; import com.mysql.jdbc.Connection; import com.mysql.jdbc.PreparedStatement; import com.mysql.jdbc.Statement; public class jdbcConn {     private static Connection connect = null;     private static Statement statement = null;     private PreparedStatement preparedStatement = null;     private static ResultSet resultSet = null;     public static void main(String[] args) throws Exception     { try {         // This will load the MySQL driver, each DB has its own driver         Class.forName("com.mysql.jdbc.Driver");         // Setup the connection with the DB         connect = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/emp?"+"user=root");         statement = (Statement) connect.createStatement();         // Result set get the result of the SQL query         resultSet = statement.executeQuery("select * from emp");       //  writeResultSet(resultSet

Example of Cursor in Mysql

DELIMITER //   CREATE PROCEDURE myone()   BEGIN                 declare myno   int(3);      DECLARE done INT DEFAULT FALSE;                 declare mycursor CURSOR for   select roll_no from fine;          DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;          open mycursor;       Label1 : LOOP                                 fetch mycursor into   myno;                               if done=TRUE then                                     leave Label1;                               end if;                              select myno;     END LOOP;     close mycursor;   END //

Integrity Constraints

Integrity Constraints There are  1.  domain integrity 2. entity integrity, 3. referential integrity  4. Enterprise  integrity constraints. Domain Integrity Domain integrity means the definition of a valid set of values for an attribute. You define  - data type,  - lenght or size - is null value allowed - is the value unique or not for an attribute. You may also define the default value, the range (values in between) and/or specific values for the attribute. Some DBMS allow you to define the output format and/or input mask for the attribute. These definitions ensure that a specific attribute will have a right and proper value in the database. Entity Integrity Constraint The entity integrity constraint states that primary keys can't be null. There must be a proper value in the primary key field. This is because the primary key value is used to identify individual rows in a table. If there were null values for primary keys, it would mean that

Armstrong's axioms

Image
Armstrong's axioms  are a set of  axioms  (or, more precisely,  inference rules ) used to infer all the  functional dependencies  on a  relational database . They were developed by  William W. Armstrong  in his 1974 paper. The axioms are  sound  in generating only functional dependencies in the  closure  of a set of functional dependencies (denoted as  {\displaystyle F^{+}} ) when applied to that set (denoted as  {\displaystyle F} ). They are also  complete  in that repeated application of these rules will generate all functional dependencies in the closure  {\displaystyle F^{+}} . Axioms  Let  {\displaystyle R(U)}  be a relation scheme over the set of attributes  {\displaystyle U} .   {\displaystyle X} ,  {\displaystyle Y} ,  {\displaystyle Z}  denotes any subset of  {\displaystyle U}  and, for short, the union of two sets of attributes  {\displaystyle X}  and  {\displaystyle Y}  denoted  by  {\displaystyle XY}  instead of the usual  {\displaystyle X\cup Y} ; this notation