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 |
What is the difference between char and varchar in mysql?
How do I edit a trigger in mysql?
How you will show all data from a table.
Does mysql support nosql?
please give me the answer for this: query which generates the second highest integer in the table?
What is offset limit?
What are ddl statements in mysql?
What are the disadvantages of mysql?
What is diff b/w MYISAM and INNODB storage engine. and also define the benifits and drawbacks of both storage engine
How can we change the name of a column of a table?
What is dbms in mysql?
How to rename an existing table in mysql?