'Creating tables in SQL with the corresponding attributes, from an ER model
If I have an ERD: https://i.stack..com/gj3Sn.png
Which I'm trying to type up in postgres SQL. How could this be done?
So far i've got:
Solution 1:[1]
You have a few typos in the CREATE TABLE ...
statements.
They work with a few changes. See below:
CREATE TABLE TradingRoute (
OperatingCompany integer,
MonitoringKey text,
LastYearRevenue integer,
Taxes integer ,
Fleet_size integer,
PRIMARY KEY (MonitoringKey)
);
CREATE TABLE Planet (
Population integer,
Name text ,
PlanetID integer ,
StarSystem integer,
PRIMARY KEY (PlanetID)
);
CREATE TABLE SpaceStation (
OperatingCompany integer,
StationID integer ,
Longitude integer ,
Name text ,
Latitude integer,
PRIMARY KEY (StationID)
);
CREATE TABLE Product (
VolumePerTon integer,
Name text ,
ValuePerTon integer,
ProductID text ,
PRIMARY KEY (ProductID)
);
CREATE TABLE RawMaterial (
FundamentalOrComposite integer,
State Date
);
CREATE TABLE Batch (
BatchID integer,
ExtractionOrManufacturingDate Date ,
PRIMARY KEY (BatchID)
);
See them running at DB Fiddle.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | The Impaler |