Design a super decoder using logic gates - boolean-logic

Truth Table
I need to design a decoder using the table given and logic gates. I dont need a complete solution but an approach or headstart on this problem. Any help is appreciated.

Some quick tips when reading the table:
A = E
B = E
C = E and Q2
D = E and (Q1 or Q2)
E = E
F = E and Q1 and Q2
G = not C
This is not the only solution; it is also possible to use variable Q0.
It is a bit strange to have a variable and an output named E.

Related

How to display values in the same line in Crystal Report

I want to display result in crystal report in same line for example i have :
1.
G1
a b c
d e f
g h i
and i want :
G1
a b c d e f g h i
If you can fix the max number of fields per line:
Section expert
Details section
Format with multiple columns
Layout tab
Width = set the desired width of each column
Printing direction = across and down

What would be an ideal mysql database strcture for a multi-level subscription web application?

Currently I am developing a system that accepts multi-level subscribers. With Laravel 5.8, MySQL.
The idea is,
An user (A) will signup with the system.
This user can suggest N number of his friends (B,C,D,...).
And B, C, D,.. can suggest N number of friends them-self after signup with the system.
Now A have his subscribers and his subscriber's subscribers.
Note, B or C or D,.. also can include A as their friend.
A
|
/ / / \ \ \
B C D L M N
| |
/ | \ |
L A D |
|
/ | \
K L M
|
/ / / \ \ \
A B C P Q R
therefore:
A's network is the major network.
both B and M can access all of the members because they have A in their list.
L don't have any list
can access all users because M is friend of D and M is friend with A.
The Structure cannot be considered as hierarchical.
I guess, Many to many relationship and join table concept needs to be implemented.
MySQL Procedure needs to be used to retrieve information.
Requirements
I need to store this relational structure in mysql DB
I should be able to retrieve unique users for any given users (MySQL Procedure).
I hope the I can get a possible suggestions and advise to build this system properly. Thank you.
You could store tree by adding parent_id column. Than, use cache to store which users (for example) user C is subscribed to (M, D, A).
It sounds like a task for graph database. Mysql is not really a great solution to be used here. You 100% will have problems with perfomance. As option, you can store only relationships in graph database (column ids), and retrieve actual data from mysql.
I know that i am a bit late, but someone can find this question through google.

Access Crosstab Report Update Columns

I have a query running in MS Access which displays employees in the first column and then pivots the status of their training tasks in the remaining columns. Statuses are simply given as completed, not required or required as shown below:
Employee Computer Business Communication
=========================================
samiro05 C NR R
bobmarley NR NR C
einstein NR R R
With this query I can run a report and change the design to be better looking and conditionally formatted to highlight areas where training is required (R). If I add more people to the source tables along with their training I can press refresh on the report and it will add a new line for the employee name just as the crosstab query now has a new row for the new employee's training. However, if I add a new training task, say Science, and update the employees' training to include Science then my crosstab query looks like this:
Employee Computer Business Communication Science
=================================================
samiro05 C NR R C
bobmarley NR NR C NR
einstein NR R R C
sheldon C C R C
...but my report when refreshed looks like this:
Employee Computer Business Communication
=========================================
samiro05 C NR R
bobmarley NR NR C
einstein NR R R
sheldon C C R
Is there a way to get the columns of my crosstab query to change within my report as my crosstab query columns increase/decrease just by refreshing the report rather than having to create the whole report again each time I add a new training/each time a new column is added or taken away from my crosstab query?
Many thanks for any help you can give with this. I will add my thoughts on how to solve this in the comments below.

MySQL LEFT JOIN issue: Retrieve workshops names in column A and a row id in column B

Apologies for the rubbish question title, but it's a bit tricky to summarise my requirement into a single line. I usually don't have an issue with MySQL JOINs but this one is throwing me.
I'm building a training feedback system and for one feature would like to display a list of all available workshops in the database, which workshops a given delegate has been assigned to and whether any feedback has been submitted by that delegate for those assigned workshops.
I could do this in a couple of queries, but I'm trying to do something a bit more elegant with a single query.
The pertinent details of my database structure:
WORKSHOPS table
id: INT
name: TINYTEXT
DELEGATES table
id: INT
name: TINYTEXT
FEEDBACK table
delegate_id: INT
workshop_id: INT
feedback: TEXT
DELEGATES_X_WORKSHOPS table
delegate_id: INT
workshop_id: INT
delegate_id and workshop_id in the tables are Foreign Keys to the DELEGATES and WORKSHOPS tables.
As any given delegate can be assigned to multiple workshops, I'm using the DELEGATES_X_WORKSHOPS table as a cross-referencing table so I can quickly search for who is assigned to any given workshop or which workshops any given delegate is assigned to.
However, I've tried LEFT JOINing a couple of different ways and I can't get a full list of workshops on the left and matches (if they exist) on the right for a given delegate_id.
Example data
Delegate Ross has delegate_id = 1
Registered workshops are
C++
PHP
ASP.NET
HTML5
JavaScript
Ross is assigned to PHP, HTML5 and JavaScript
Question 1 is this: how do I return the following for delegate_id=1:
[workshop] | [assigned]
C++ | null
PHP | TRUE
ASP.NET | null
HTML5 | TRUE
JavaScript | TRUE
(it doesn't matter right now what goes into column B, I just want a null if a particular delegate_id hasn't been assigned to a workshop).
I've used this:
SELECT
workshops.name,
delegates_x_workshops.delegate_id
FROM
workshops
LEFT JOIN
delegates_x_workshops
ON
workshops.id=delegates_x_workshops.workshop_id
WHERE
delegates_x_workshops.delegate_id=1
However I'm only returning the 3 rows where delegate_id=1, not 5 rows for all workshops.
Question 2 is a bit more involved:
Taking question 1 as a base, how would I work column C to display if feedback has been left for a workshop that Ross has been assigned to?
[workshop] | [assigned] | [givenfeedback]
C++ | null | null
PHP | TRUE | TRUE
ASP.NET | null | null
HTML5 | TRUE | null
JavaScript | TRUE | TRUE
Thanks in advance to anybody who makes it this far and has a clue what I'm blithering about. As I said, I could rattle through this with a few different queries, but I'm trying to keep things elegant.
No doubt half of this will need clarification, so ask any questions.
Thanks
For question 1, you need to move the where condition into the on clause. It is turning the left outer join into an inner join because non-matching rows have NULL values:
SELECT w.name, dxw.delegate_id
FROM workshops w LEFT JOIN
delegates_x_workshops dxw
ON w.id = dxw.workshop_id and
dxw.delegate_id = 1;
For the second question, I think this is what you want:
SELECT w.name,
(case when max(w.name = 'Ross') > 0 then 'True' end) as Assigned,
(case when count(f.workshop_id) > 0 then 'True' end) as Feedback
FROM workshops w LEFT JOIN
delegates_x_workshops dxw
ON w.id = dxw.workshop_id and
dxw.delegate_id = 1 LEFT JOIN
delegates d
on d.id = dxw.delegate_id LEFT JOIN
feedback f
on f.workshop_id = w.id
GROUP BY w.name;
For reference, here's my final query:
SELECT DISTINCT
workshops.id AS wid,
workshops.name AS workshop,
(delegates_x_workshops.delegate_id IS NOT NULL) AS assigned,
(initial_feedback.delegate_id IS NOT NULL
OR
ongoing_feedback.delegate_id IS NOT NULL) AS hasfeedback
FROM
workshops
LEFT JOIN
delegates_x_workshops
ON
workshops.id = delegates_x_workshops.workshop_id
AND
delegates_x_workshops.delegate_id = 1
LEFT JOIN
initial_feedback
ON
workshops.id = initial_feedback.workshop_id
AND
initial_feedback.delegate_id = 1
LEFT JOIN
ongoing_feedback
ON
workshops.id = ongoing_feedback.workshop_id
AND
ongoing_feedback.delegate_id = 1
ORDER BY
workshop ASC
For every workshop in the WORKSHOPS table, I'll get the id and name of the workshop, 1 or 0 if a given delegate_id is assigned and 1 or 0 if feedback of either type (I have 2 kinds) has been left for that workshop.
Scary to think that all I was missing was an AND condition on my LEFT JOIN.
Thanks again Gordon!

DatabaseDesign for a Traveller

I'm currently having problems designing a database. I'm building a small car sharing plattform and im quite unsure how to store 'sharing offers'.
I have people travelling from A to D (via B, C)
A → B → C → D
And i've ppl travelling from C to D.
I thought about splitting the first trip into subtrips (A→B, B→C, C→D). With a "join" on B i could find connections from A → C. But with more intermediate steps, this would become quite slowly (I assume), keep in mind that you shouldn't change the driver/car during one ride.
I read something about 'nested sets', to build up a tree. But I'm not sure if this approach would fit for my problem, as i don't have a root (and i've no clue how to traverse that tree in sql). At the moment i dont know wherelse to start. If you confirm the use of nested sets, i'll dive into that.
But I appreciate any other ideas or suggestion
ps. this is my first post, i hope i got everything right :)
How about one row per stop during a trip, including the order number of the stop? Like this:
trip | stop | place
-----+------+------
1 | 1 | A
1 | 2 | B
1 | 3 | C
1 | 4 | D
That way you can easily find trips that go e.g. from A to C:
SELECT t.trip
FROM trips t
JOIN trips s ON (
t.trip = s.trip AND
t.place = "A" AND
s.place = "C" AND
t.stop < s.stop
);
This way the query will always be the same, regardless of subtrips.