ASDV-WebDev/Semester 3/Assignments/nyse-1.sql

110 lines
2.8 KiB
SQL

-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Mar 25, 2024 at 02:28 PM
-- Server version: 5.7.39
-- PHP Version: 7.4.33
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `nyse`
--
-- --------------------------------------------------------
--
-- Table structure for table `stock`
--
CREATE TABLE `stock` (
`stock_id` varchar(4) NOT NULL,
`company_name` varchar(100) NOT NULL,
`price_current` double NOT NULL,
`price_closing` double NOT NULL,
`number_of_shares_available` bigint(20) NOT NULL,
`number_of_shares_sold` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `stock`
--
INSERT INTO `stock` (`stock_id`, `company_name`, `price_current`, `price_closing`, `number_of_shares_available`, `number_of_shares_sold`) VALUES
('AMZN', 'Amazon Inc.', 6, 188, 7779754, 1111),
('GOO', 'Google Inc.', 986, 399, 1000000, 1000000),
('PLCE', 'Children\'s Place, Inc.', 14.515, 13.515, 10000000, 5000000),
('TSLA', 'Tesla Inc.', 191.73, 202.98, 4000000, 1000000);
-- --------------------------------------------------------
--
-- Table structure for table `stock_holder`
--
CREATE TABLE `stock_holder` (
`stock_holder_id` int(11) NOT NULL,
`name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `transactions`
--
CREATE TABLE `transactions` (
`stock_holder_id` int(11) NOT NULL,
`stock_id` varchar(4) NOT NULL,
`qty` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `stock`
--
ALTER TABLE `stock`
ADD PRIMARY KEY (`stock_id`);
--
-- Indexes for table `stock_holder`
--
ALTER TABLE `stock_holder`
ADD PRIMARY KEY (`stock_holder_id`);
--
-- Indexes for table `transactions`
--
ALTER TABLE `transactions`
ADD PRIMARY KEY (`stock_holder_id`,`stock_id`),
ADD KEY `stock_id` (`stock_id`);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `transactions`
--
ALTER TABLE `transactions`
ADD CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`stock_id`) REFERENCES `stock` (`stock_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `transactions_ibfk_2` FOREIGN KEY (`stock_holder_id`) REFERENCES `stock_holder` (`stock_holder_id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;