Guest User

Database_Structure

a guest
Apr 9th, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DROP DATABASE IF EXISTS  riversData;
  2.  
  3. -- create a new database as riverData--
  4. CREATE DATABASE riversData;
  5.  
  6. -- set this database as current working database
  7. USE riversData;
  8.  
  9. -- initilly we are asumming that there are only two rivers
  10.  
  11.  
  12. --  table to store the id's of the various sensors of river1
  13. CREATE TABLE river1Nodes(
  14. nodeId INTEGER PRIMARY KEY
  15. location varchar(255),
  16. );
  17.  
  18.  
  19. -- table to store the id's of the various sensors of river2
  20. CREATE TABLE river2Nodes(
  21.  nodeId INTEGER PRIMARY KEY,
  22. location varchar(255),
  23. );
  24.  
  25. -- table to store the sensor's data situated various location in river 1 at a timestamp
  26. CREATE TABLE river1Data(
  27. pressure FLOAT,
  28. moisture FLOAT,
  29. atTime TIMESTAMP,
  30. nodeId INTEGER,
  31. FOREIGN KEY (nodeId) REFERENCES river1Nodes(nodeId)
  32. );
  33.  
  34. -- table to store the sensor's data situated various location in river 2 at a timestamp
  35. CREATE TABLE river2Data(
  36.  pressure FLOAT,
  37.  moisture FLOAT,
  38.  atTime TIMESTAMP,
  39.  nodeId INTEGER,
  40.  FOREIGN KEY (nodeId) REFERENCES river2Nodes(nodeId)
  41.  );
Add Comment
Please, Sign In to add comment