A company wants to store their invoices in a database. They
already have their customers and articles in that database.
Both customer and article are each identified by an unique
integer value. Please create the SQL statements for
creating the necessary table(s) for storing the invoices in
a MySQL database. An invoice should hold information like
invoice number, customer, date, article(s) and quantity
etc.
Answer / frank
Assume existing tables for customer and article are:
customers
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra
|
+------------+----------+------+-----+---------+----------------+
| customerId | int(11) | NO | PRI | NULL |
auto_increment |
| customer | char(50) | NO | | NULL |
|
+------------+----------+------+-----+---------+----------------+
article:
+-----------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+----------------+
| articleId | int(11) | NO | PRI | NULL | auto_increment |
| article | char(50) | NO | | NULL | |
+-----------+----------+------+-----+---------+----------------+
CREATE TABLE invoices (invoiceId INT AUTO_INCREMENT PRIMARY
KEY,customerId INT NOT NULL,articleId INT NOT
NULL,invoiceNumber CHAR(20) NOT NULL UNIQUE,invoiceDate DATE
NOT NULL,quantity INT NOT
NULL,INDEX(customerId),INDEX(articleId));
Is This Answer Correct ? | 3 Yes | 0 No |
How do I connect to mysql database?
What is query design?
What does mysql_fetch_assoc do?
What could be the reason that the mysql statement 'select avg (salary) from emp' generates an inaccurate output?
How do I restore a mysql database?
How do I run mysql from command line?
How do you flush privileges?
How to display top 50 rows?
What is mysql protocol?
mazimum size of a database in mysql? when we create a table then how many tables actually created? write there name?
Can you tell how many values can set the function of mysql to consider?
Is oracle mysql free?